1

I changed a website and now Google webmaster is loading hundreds of "Not Found" URLs:

http://www.domain.com/images/picture.php?idphotos=720,404,,4/1/13,Not found

The picture.php does not exist anymore so I created a .htaccess entry to redirect the root of the site:

Redirect 301 /images/picture.php. /

Now the problem is that any query parameters are also sent in the redirect:

http://www.domain.com/?idphotos=720

How can I create a redirection which doesn't include the query parameters, e.g. like this:

http://www.domain.com/

2 Answers 2

7

Try this (note the trailing ?):

RewriteCond %{QUERY_STRING} !=""
RewriteRule . http://www.domain.com/?
Sign up to request clarification or add additional context in comments.

Comments

4

Alternatively use the QSD flag from Apache 2.4.0

RewriteCond %{QUERY_STRING} !=""    
RewriteRule . http://www.domain.com/ [L,R=301,QSD]

http://httpd.apache.org/docs/current/en/rewrite/flags.html#flag_qsd

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.