Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Htaccess redirects on Apache

  1. Sep 5, 2008 #1

    CRGreathouse

    User Avatar
    Science Advisor
    Homework Helper

    I'm running an Apache server, but I'm having trouble redirecting files. I've tried including lines like

    Code (Text):
    Redirect permanent /oes.htm [PLAIN]https://example.com/file.html[/PLAIN] [Broken]
    [/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 (Text):
    Redirect /oes.htm [PLAIN]https://example.com/file.html[/PLAIN] [Broken]
    Redirect 301 /oes.htm [PLAIN]https://example.com/file.html[/PLAIN] [Broken]
    [/URL]

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


    I'm including alias_module already:
    Code (Text):
    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: May 3, 2017
  2. jcsd
  3. Sep 5, 2008 #2
    Here is an example of what PF does for it's blogs. Top of the htaccess file.

    Code (Text):
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) [PLAIN]https://www.physicsforums.com/blog.php$1[/PLAIN] [Broken] [R=301,L]
     
    Last edited: May 3, 2017
  4. Sep 29, 2008 #3
    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 (Text):
    RedirectMatch \/oes.htm$ [PLAIN]https://example.com/file.html
    [/PLAIN] [Broken]
    The first parameter is a regex, of course, with the slash escaped and "$" signifying end-of-string.
     
    Last edited by a moderator: May 3, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Htaccess redirects on Apache
  1. Apache error webpage (Replies: 4)

  2. Forbidden apache error (Replies: 3)

  3. Apache Virtual Host (Replies: 2)

Loading...