我使用的是PHP的RouteMap并希望清理URL。需要一些mod_rewrite规则的帮助
URL的进来的形式:
http://localhost/subfolder/index.php?controller/method/arg1
如何将它转换为:
http://localhost/subfolder/controller/method/arg1
我使用的是PHP的RouteMap并希望清理URL。需要一些mod_rewrite规则的帮助
URL的进来的形式:
http://localhost/subfolder/index.php?controller/method/arg1
如何将它转换为:
http://localhost/subfolder/controller/method/arg1
没有测试过,但我想你会希望以下内容:
RewriteRule ^/subfolder/controller/(method/.*)$ /subfolder/index.php?controller/$1
你可以在你的httpd.conf文件中试试这个:
#start your engine
RewriteEngine on
#add www. for any url, not what you asked for, but kinda helpful SEO-wise
RewriteCond %{HTTP_HOST} ^mypage\.com
RewriteRule ^(.*)$ http://www.mypage.com$1
#rewrite stuff
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?$1
这应该有效。我会改变最后一行,tho:
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?p=$1
现在,在重新启动apache之前,尝试测试配置文件是否正常。
user$ apachectl configtest
就是这样。
希望它有帮助。
干杯
RewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1 [R]
RewriteRule ^products/([0-9][0-9])$ /products/$1/
在同.htaccess文件多次重定向可以按顺序,这是什么这样做可以应用