homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Missing something very basic with 301 & 404 redirects

 6:14 pm on Sep 5, 2013 (gmt 0)

My assumption is that you could mix 301 and 404 lines in .htaccess files so that you can redirect specific pages and then use a 404 redirect to mop up the rest to a custom 404 error page.
But seemingly not?

My assumption was something like that below, but no it doesn't seem to like it.

Redirect 301 /1.htm /a.htm
Redirect 301 /2.htm /b.htm
Redirect 301 /3.htm /c.htm
Redirect 404 /custom404.htm

Am I going about this in entirely the wrong manner or is the objective just not possible, its 301 or 404 but not both?



 6:42 pm on Sep 5, 2013 (gmt 0)

Redirect 404 /custom404.htm

You don't want to redirect to an error document, but rather use ErrorDocument for the appropriate status code.

ErrorDocument 404 /custom404.htm

[Delinked to preserve fragment identifier]


 7:30 pm on Sep 5, 2013 (gmt 0)

Grrr I knew it was something simple right in front of me.



 8:14 pm on Sep 5, 2013 (gmt 0)

Redirect 404 /custom404.htm

This line doesn't mean "send user to custom error document". It means "respond to requests for this named document with a 404" presumably leading to exactly the same type of 500-class error that arises when you neglect to poke a hole for your custom 403 document.

:: detour to check something ::

Thought so. The numerical status code in mod_alias behaves exactly the same as the argument to the [R] flag in mod_rewrite: if it's outside the 3xx range, the server simply returns the specified response.

Which reminds me that when I saw the subject line I was afraid it would be a question about mixing mod_alias and mod_rewrite in a single htaccess file.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved