1

Search engines crawl the site with parameters

/?p=([0-9]+)
/?cat=([0-9]+)
/?do=([a-z]+)

etc

How make in .htaccess to inform the search engines that such pages no longer exists?

I have only /?page=([0-9]+)

Thanks.

I tried

RewriteCond %{QUERY_STRING} ^(p|cat|do)(.*)$
RewriteRule ^$ http://test.com/simple [R=301,L]

but

http://test.com/?p=23 give me http://test.com/test?p=23 (not http://test.com/test)
http://test.com/?cat=11 give me http://test.com/test?cat=11 (not http://test.com/test)

2 Answers 2

1

I would suggest following 301 (Permanent Redirect) rule for you:

RewriteCond %{QUERY_STRING} !^page=.*$ [NC]
RewriteRule ^$ http://test.com/test? [R=301,L]

This will redirect every /?p=([0-9]+) or /?do=([0-9]+) or /?foo=([0-9]+) or /?bar=([0-9]+) etc (any query string except /?page=) to http://test.com/test with R=301 and remove the original query string (notice ? in the end of target URL).

Sign up to request clarification or add additional context in comments.

Comments

0

You could add those pages to your robots.txt file to prevent the indexing.

However, somewhere the search engines are finding these links. You should ensure that you are not using them on your site.

If the pages no longer exist, you might consider redirecting (301) them accordingly.

The latter, or some combination therein should sort you out.

2 Comments

robots.txt only for search engines, I need this to work also for users.
I already did it. Not as I would like, but it works. RewriteCond %{QUERY_STRING} ^(p\=|cat\=|do\=|feed\=|tag\=|m\=|paged\=)(.*)$ RewriteRule ^$ http://www.test.com/\? [R=301,L]

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.