Justin
Justin

Reputation: 33

Removing a page from google index

I've been having a problem with redirecting a page on my website from google index via htaccess files. I've been using

Redirect 301 http://example.com/?attachment_id=99 http://example.com

but it doesn't do anything..

anyone know of a better way to fix this problem?

my goal is to get it from index on google.

Upvotes: 1

Views: 233

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

You need to use mod_rewrite to match against query strings .

Try this in htaccess :

RewriteEngine On

RewriteCond %{QUERY_STRING} ^attachment_id=99$  
RewriteRule ^/?$ http://example.com? [NC,L,R] 

Empty question mark at the end of the target url is important ,as it discards the orignal query strings.

Upvotes: 1

Related Questions