I have a problem whereby google has indexed some pages with the wrong url.
The url they are indexing is:
1. http://www.mydomain.com/index.php?a=profile&u=john
2. http://www.mydomain.com/index.php?a=page&b=about
3. http://www.mydomain.com/index.php?a=settings&b=avatar
4. http://www.mydomain.com/index.php?a=feed
5. http://www.mydomain.com/index.php?a=feed&filter=picture
6. http://www.mydomain.com/index.php?a=post&m=32
7. http://www.mydomain.com/index.php?lang=english
8. http://www.mydomain.com/index.php?a=messages&u=john&id=4
9. http://www.mydomain.com/index.php?a=feed&logout=1
I need it to redirect to:
1. http://www.mydomain.com/john or http://www.mydomain.com/profile/john
2. http://www.mydomain.com/about or http://www.mydomain.com/page/about
3. http://www.mydomain.com/settings/avatar
4. http://www.mydomain.com/feed
5. http://www.mydomain.com/feed/picture or http://www.mydomain.com/feed/filter/picture
6. http://www.mydomain.com/message/32
7. http://www.mydomain.com/lang/english
8. http://www.mydomain.com/messages/john
9. http://www.mydomain.com/logout or http://www.mydomain.com/feed/logout
.htaccess isn't my forte, so any help would be much appreciated.
Thanks in advance.
Edit:
Ok, I got it working by using two method by Dan Trimper and Jon Lin. First I'm generate mod rewrite url by using Dan Trimper method. For example
http://www.mydomain.com/index.php?a=page&b=about
, so after generate it will produce the url like thisRewriteRule ^([^/]*)/([^/]*)$ /index.php?a=$1&b=$2 [L]
-
Second, after generate I'm using second method redirect url to
http://www.mydomain.com/page/about
by using Jon Lin method:RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\?a=page&b=([^&\ ]+) RewriteRule ^ /page/%1? [L,R=301]
Thank you!
Edit 2: Not working above because conflict. More accurate solution goes to this topic .htaccess friendly URl