我有一個問題,谷歌索引了一些頁面的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