Apache, modifying response codes from 404 to 301

Posted by user72539 on Server Fault See other posts from Server Fault or by user72539
Published on 2011-02-28T22:22:18Z Indexed on 2011/02/28 23:26 UTC
Read the original article Hit count: 414

Filed under:
|
|

Hi,

I'm running a magento installation on an apache server. There are many pages indexed in both google and linked to from external sites.

I can't use 301 redirects in a .htaccess file as I can't be sure I will catch all the links. At the moment all requests are rewritten through magento and if a request isn't found magento returns a 404 File not Found.
Is there a way of using one of the apache modules to filter the response* from magento and if a 404 Not Found is being sent back then replace the response with a standard 301 Redirect to the home page?

E.g.

Request to Magento --> Apache --> Rewrite to Magento index.php page --> page processed.

Response if request exists --> return results (200) if request doesn't exist --> return 404 --> apache filter change response --> return 301 redirect to /

I appreciate any help.

Thanks,

Jon

  • as far as I am aware mod_rewrite is only used to rewrite requests and doesn't allow the modification of responses.

© Server Fault or respective owner

Related posts about apache

Related posts about rewrite