Why is my Htaccess redirect not working on Apache server?

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    apache
AI Thread Summary
Redirecting files on an Apache server can be challenging, especially when standard methods like the Redirect directive in the httpd.conf or .htaccess files do not yield the expected results. Users have reported issues with the Redirect command not functioning as intended, resulting in the original file being loaded instead of the target URL. It is important to ensure that the alias_module is correctly loaded with the directive "LoadModule alias_module modules/mod_alias.so." An alternative approach that has proven effective is using RedirectMatch, which allows for regular expression matching. For example, the command "RedirectMatch \/oes.htm$ https://example.com/file.html" can successfully redirect requests by matching the end of the string. This method may resolve issues that arise with standard Redirect commands, particularly when configuring redirects for specific file types or patterns.
CRGreathouse
Science Advisor
Homework Helper
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:
Computer science 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:
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Sorry if 'Profile Badge' is not the correct term. I have an MS 365 subscription and I've noticed on my Word documents the small circle with my initials in it is sometimes different in colour document to document (it's the circle at the top right of the doc, that, when you hover over it it tells you you're signed in; if you click on it you get a bit more info). Last night I had four docs with a red circle, one with blue. When I closed the blue and opened it again it was red. Today I have 3...

Similar threads

Back
Top