1
我想服务于不同的网址使用mod_rewrite,但无论我尝试它只是不工作。URL重写.htaccess
一个例子网址是 http://www.site.com/country/tours/dynamic-part/?&city=new-york,los-angeles
,我试图用的.htaccess来更改URL:
http://www.site.com/country/tours/dynamic-part/new-york,los-angeles
RewriteEngine on
RewriteBase/
RewriteCond %{QUERY_STRING} (^|&)city=([^&]*)(&|$)
RewriteRule ^country\/tours\/([a-zA-Z0-9]*)\/.+city=([^\/]*)$ http://www.site.com/country/tours/$1/$2 [L,R=301]
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
任何想法?不过,我觉得我很接近但现在不是了:/
我把它放在我的.htaccess(它不会像我的修改那样返回500个内部服务器错误),但它不会删除城市参数。我正在使用http://htaccess.madewithlove.be/来测试我的htaccess。 – GeorgeKaf
检查你的错误日志,找到它不喜欢的文件。你怎么知道该网站是可靠的。另一个有趣的点是你的'动态部分'示例包含一个连字符,但这不在你的正则表达式中。你可能也想要qsdiscard。 – barryhunter
我会进一步探讨它谢谢你。 – GeorgeKaf