Note: This might be a post that should go in the Apache forum - I wasn't sure so I just posted it here. Feel free to move it. I am trying to get all error pages on my site automatically redirected via a 301 permanent redirect to the home page. In other words, I want digitalpoint.com/3feafioajjdpsfja/ to redirect to http://www.digitalpoint.com/ . Right now, I have a custom 404 error page set up in the .htaccess, but the problem is that the server gives a 302 redirect from the error page to the custom error page, and from there, I have a php script set up to give a 301 redirect to the home page. Is there any way to elminate the 302 redirect, or change it to a 301? My goal is to get a redirect that the search engines will follow from any error page to the home page. Thank you!
You could try mod_rewrite for that. It allows for making such smart things. It's not easy to use, however.
Mod_Rewrite wouldn't work in this case, because I wouldn't know what url's people would type in. I simply want all url's that would normally get a 404 to instead get a 301. Also, could a mod please move this topic to the Apache forum? I probably should have posted it there to begin with. Thanks,
For above example: RewriteRule ^/3feafioajjdpsfja/$ http://www.digitalpoint.com/ [R=301,L] Hope this helped.
Well, that would take care of that particular example, but then, what if someone happened to type in digitalpoint.com/aewfeioa/? I am looking for a way to send all pages that would normally get a 404 error (all pages that don't exist) to another page via a 301 redirect. I can set up a custom error page, that then redirects via a 301 to the home page, but the server gives a 302 redirect from the bad url to the custom error page, and I want to eliminate that 302. Thanks for the code, though, I'll use it in another project.
I use something like: RewriteRule ^(.*)$ process.php This directs all requests to process.php where I can determine the validity of the URL and get the files requested. -phil