1
我想htaccess的重定向301執行以下操作: 「article.php ID」的.htaccess更換零件鏈接的
http://mysite.com/article.php?id=123
到
http://mysite.com/123
換句話說,去除部分
任何幫助將不勝感激。
我想htaccess的重定向301執行以下操作: 「article.php ID」的.htaccess更換零件鏈接的
http://mysite.com/article.php?id=123
到
http://mysite.com/123
換句話說,去除部分
任何幫助將不勝感激。
使用此代碼在您的.htaccess文件:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([^&]*)(&|$) [NC]
RewriteRule ^article\.php$ /%1? [L,R=301,NC]
它使用?
到底要擺脫是非常重要的原始查詢字符串。
你可以,如果它啓用了mod_rewrite
做到這一點:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^article\.php$ http://%{HTTP_HOST}/%1 [L,R=301]
對不起,我忘了它是php?id =而不是php?= – boruchsiper 2011-06-13 14:54:39
我修正了它(參見第二行) – Floern 2011-06-13 15:00:14