Why is my Htaccess redirect not working on Apache server?

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    apache
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Messages
2,832
Reaction score
0
I'm running an Apache server, but I'm having trouble redirecting files. I've tried including lines like

Code:
Redirect permanent /oes.htm [PLAIN]https://example.com/file.html[/PLAIN]
[/URL]

in the httpd.conf file as well as in an .htaccess file, but loading the URL in the browser I only get the original file, not the file I'm redirecting to. Neither of

Code:
Redirect /oes.htm [PLAIN]https://example.com/file.html[/PLAIN] 
Redirect 301 /oes.htm [PLAIN]https://example.com/file.html[/PLAIN]
[/URL]

work (though all three should be the same, I think, unless Redirect gives a 302 instead).


I'm including alias_module already:
Code:
LoadModule alias_module modules/mod_alias.so

What am I doing wrong? Is there something else I need to configure?
 
Last edited by a moderator:
Physics news on Phys.org
Here is an example of what PF does for it's blogs. Top of the htaccess file.

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [PLAIN]https://www.physicsforums.com/blog.php$1[/PLAIN]  [R=301,L]
 
Last edited:
I remember that getting the Redirect directive to work was a pain in the butt, and I ended up having to use RedirectMatch instead, but I don't remember exactly why... try this instead maybe?
Code:
RedirectMatch \/oes.htm$ [PLAIN]https://example.com/file.html
[/PLAIN]
The first parameter is a regex, of course, with the slash escaped and "$" signifying end-of-string.
 
Last edited by a moderator: