I'm using the following directives in .htaccess to redirect only example.com/script-dir/index.php (with www and without) to example.com/index.php. But it also redirects example.com/script-dir/index.php?page=faq and other pages.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^script\-dir\/index\.php$ "http\:\/\/example\.com\/" [R=301,L]
What should I do to redirect only that single page?
Best Answer
The query string (
?page=faq
) isn't part of the URL that gets tested in the RewriteRule, so you have to add a separate condition to test it:I'm not sure why other pages would get redirected though.