我需要根据用户代理重写我们的url . 我可以使用apache RewriteCond过滤用户代理,但我的重写规则不起作用 . 这就是我需要的 .

原始网址

https://www.myhost.com/#!/string1/string2/myitem/

对此

https://www.myhost.com/string1/m/string2/myitem.html

请注意, #! 符号已删除

我的配置是这样的 .

RewriteCond %{REQUEST_URI} /([^/]+)/$

#Now redirect to the mobile site
RewriteRule ^ https://%{HTTP_HOST}/string1/m/%1.html [R,L]

我的服务器是Centos 6.4和httpd-2.2.15 . 在此先感谢您的帮助 .