1

I have a .txt file on my hosting and would like to redirect to it if somebody enters an specific website within their browser, e.g.

example.com/webpage  -->  redirects to  --> example.com/webpage.txt

I have tried few rewrite rules, but without success. Is it even doable like this?

  • 4
    Please show what you have tried and what other directives you have in your .htaccess file. This should be a simple redirect, so if it's not working then there may be a conflict with other directives, or maybe there is a minor error with your attempt. – MrWhite Sep 1 at 20:24
  • Not sure if this belgian link will work for you but I use this tool to test my htaccess htaccess.madewithlove.be – gael Sep 2 at 9:46
0

Using mod_alias:

Redirect permanent /webpage https://example.com/webpage.txt

or if you are using a recent version of Apache, you can redirect to relative URLs:

Redirect permanent /webpage /webpage.txt

You can also implement this with mod_rewrite:

RewriteEngine On
RewriteRule "^/?webpage$" "/webpage.txt" [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.