Search code examples
http-redirecturl-rewritingurl-routinghttp-status-code-301

I need a 301 redirect


Can someone help me with a rule that will redirect any url that begins with someDomain/catalog/product_info.php and have it redirect to the site's homepage?


Solution

  • If your site is e. g. example.com and you want to redirect a request for http://example.com/catalog/product_info.php to http://example.com, you can do this (for Apache):

    RewriteEngine On
    
    RewriteRule ^catalog/product_info\.php$ / [R=301,L]
    

    Keep in mind that an HTTP/301 redirect is a 'Site Moved Permenantly'; if this is temporary, use a 302, or just silently rewrite the URL without redirecting the HTTP client (omit the R=301 from the Rewrite Rule flags).