1

I made a mistake (I don't know how) on my .htaccess and a part of my artilcle's links on Google have changed from:

mysite/articles/isfahan_articlesXXX.html

To:

mysite/maghalat.php/isfahan_articlesXXX.html?id=XXX 

Where XXX is article's ID. My current .htaccess part that contains articles is:

RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1
Redirect 301 ^maghalat.php/isfahan_articles([0-9]+).html?id=([0-9]+)$ mysite/articles/isfahan_articles$1.html

However it still will not redirect:

mysite/mghalat.php/isfahan_articlesXXX.html?id=XXX 

To:

mysite/articles/isfahan_articlesXXX.html

I would also like to remove this link from Google:

mysite/articles/isfahan_articlesXXX.html
3
  • The best advice on such situation: yes, you can mess around with redirects if you want (although it is not trivial task considering situation as you may easily create infinite redirect), but instead just use <link rel="canonical" href="PROPER_URL" /> and within a month or two (or even faster) Google will forget your wrong URLs in favour of correct one (as long as you will not publish wrong URLs on your site again). Just google for "link rel canonical" for exact instructions. Commented Aug 23, 2011 at 12:20
  • Regarding your redirect attempts: 1) Redirect & RedirectMatch directives do not match query strings. You current rule will NEVER match; 2) You are using regex in Redirect directive -- should be RedirectMatch -- read the docs; 3) Even then -- URL is wrong as it should start with leading slash; 4) The only way to match query string is to use RewriteRule in conjunction with RewriteCond; 5) You still can easily create redirect loop -- the rewrite rule has to be quite sophisticated to handle this. Considering all of the above -- go rel=canonical route. Commented Aug 23, 2011 at 12:23
  • What can I do please say me a practical way , by example please Commented Aug 26, 2011 at 11:48

3 Answers 3

1

When you redirect using a 301 (moved permanently) status code, it will disappear from Google eventually.

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

7 Comments

do you mean my code: Redirect 301 ^maghalat.php/isfahan_articles([0-9]+).html?id=([0-9]+)$ mysite/articles/isfahan_articles$1.html is correct?! but when I try to open it it wont redirect to mysite/articles/isfahan_articlesXXX.html that show its a wrong rule , isn't it?
Ah, I see.. So the problem is, you do want the rewrite to mghalat (under water), but it shouldn't appear in Google.. The problem now, is that you can't both redirect the .php requests (from Google) to the .html file, and still push the .html requests to the .php file. You'll need to rename the .php file if you want to keep using that internally. If this is what you mean, let me know and I'll post some htaccess rules that should work for you.
Yes I want to replace maghalat.php to articles and remove id=XXX in : mysite/maghalat.php/isfahan_articlesXXX.html?id=XXX from Google
But do you still use maghalat for processing?
No maghalat.php is my php script that show article's body , I have 2 SEO friendly links on my .htaccess : one of them is for my old articles with following link : mysite/articles/isfahan_articlesXXX.html that currently have changed into Search Engines to mysite/maghalat.php/isfahan_articlesXXX.html?id=XXX , I wont to have this link on Search Engines it shows my PHP script and dropped my ranking ,I want to have my old link instead for my old articles : mysite/articles/isfahan_articlesXXX.html simply
|
1

To remove pages from Google's index you need to create a google account and use Google Webmaster Tools. Add your website and Follow the instruction to validate that you are the owner of the site. There is an option to remove urls.

The pages you want to remove must meet some criteria: They need be access restricted or return a 404 or 410 error code.

When the old urls are of your articles are blocked or removed, it's just a matter of time until the new ones will appear again in the google index.

1 Comment

I wont to remove it I want to change it to my old style : mysite/articles/isfahan_articlesXXX.html , actually I want replace "maghalat.php" to "articles" in my current link: mysite/maghalat.php/isfahan_articlesXXX.html?id=XXX and remove ?id=XXX
0

You should check your links, its seems that this pages are created because of an error somewhere. But I'm just guessing.

You also can add a pattern in your robots.txt that disallow robot to crawl your pages.

Regards,

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.