To be honest, I'm not an expert on website SEO, not even good at it. The reason pushing me to write it down is because it buggied me a lot, and finally I fixed it.

Here is the story, I see a lot of error from google webmaster complaining link not found, here is few examples:

They look like dynamic urls, but actually the urls are all wrong. They were all generated by the CMS when google crawer craws my site, I don't see these kind of urls during regular access, so I have no idea how they did they get generated.

It took me a lot of time to fix it. Tried to fix by blocking them in robot.txt, also tried in google webmaster url parameter, seems non of them works perfectly.

Directly update mysql table redirect_links  seems working, force the old wrong link to get redirected a new link, but new wrong urls keeps coming out, so I decided to find a permenent solution.

At the end, I tried .htaccess rewrite, it works right for me. Here are mod_rewrite rules i used for my site.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*catid=[0-9]+&id=(.*)$
RewriteRule .*   %1? [R]

For example, it translate the url


How it wrks?

The first line turns rewrite engine on
The second line using QUERY_STRING to search string pattern 
^.* matches all characters from the begining of the QUERY_STRING,
in this example, it's 'scripting?'
[0-9]+ matches any integer number. In this example, it's 0.
The third line rewrite old url to the strings after id=. It's 143 in above example

Number 143 is the article id from the old url, by just using the id, my website can figure out which page I'm looking for.

As you can see the translated url is still a dynamic url, its static url actually is


During the bug fix, I found these links are pretty good, thanks

This one is a htaccess tester, pretty handy


Comments powered by CComment