我试图在ubuntu 14.04中的apache2服务器上重写.htaccess的url。我有以下网址:
localhost/compare/compares/single/16/postoneVSposttwo
但我希望它像:
localhost/compare/compares/postoneVSposttwo
我试过遵循.htaccess规则:
RewriteEngine on
RewriteRule ^(.+)/single/.+/(.+)$ $1/$2 [L,NC,R]
但它有一个网址:
localhost/var/www/html/compare/webroot/compares/postoneVSposttwo
我该如何解决这个问题?
答案 0 :(得分:1)
您可以使用此规则:
RewriteEngine on
RewriteRule ^(.+?)/single/[^/]+/(.+)$ /compare/$1/$2 [L,NC,R=302]