0

I currently have this code in my .htaccess file

RewriteCond %{QUERY_STRING} !product_id=(.*)
RewriteRule ^(.*)$ http://www.myurl.com/index.php [R=301]

This 301 redirects product URLs to my root directory based on product ID. (I didn't make it I got it from someone else)

What I need to do is keep this rule in place whilst redirecting any 404 pages in the same directory to the homepage.

4

1 に答える 1

0

既にあるルールの前にこれらのルールを追加してみることができます:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /? [L,R=301]

これは、あなたが話しているホームページがドキュメントルートであることを前提としています。たとえば、/blahが存在せず、通常は 404 になる場合、に移動するhttp://yourdomain.com/blahと にリダイレクトされhttp://yourdomain.com/ます。

于 2013-02-28T11:01:06.903 に答える