我有一个问题,谷歌索引了一些页面的URL错误。.htaccess从url中删除index.php和其他人
的URL他们索引是:
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
我需要它重定向到:
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是不是我的专长,所以任何帮助,将不胜感激。
在此先感谢。
编辑:
好吧,我把它用两个方法,通过丹特林皮尔斯和Jon林工作。首先,我使用Dan Trimper方法生成mod重写url。例如
http://www.mydomain.com/index.php?a=page&b=about
,所以产生以后,会通过乔恩·林法产生的URL这样RewriteRule ^([^/]*)/([^/]*)$ /index.php?a=$1&b=$2 [L]
其次,生成我使用第二种方法重定向的URL
http://www.mydomain.com/page/about
后:的RewriteCond%{} THE_REQUEST^[AZ] {3,9} \ /index.php\?a=page & b =([^ & \ ] +)RewriteRule ^/page /%1? [L,R = 301]
谢谢!
编辑2:没有工作,因为冲突。更准确的解决方案进入这个话题.htaccess friendly URl
看看Mod重写http://httpd.apache.org/docs/current/mod/mod_rewrite.html – lampwins