2011-06-15 85 views
0

我在运行中遇到了一个网址问题。Apache有条件的重写规则

我想找到,并以URL的,像这样的中间替换字符串:

localhost/existing/template-one/index.html 

需要改变,以

localost/template-one/index.html 

唯一需要注意的是,/模板的一个/也可以是/ template-two /或/ template-three等等。

所以基本上,我们看到/ template-something跟在/存在/我们想摆脱/存在

到目前为止,我有这样的:

^/existing/?(.*) /$1 

,但这种情况在所有情况下,而不是条件!

任何帮助将不胜感激。

感谢

回答

0

使用以下规则:

RewriteRule ^existing/template-(.*) template-$1 

括号将existing/template-后匹配任何东西,它重写template-<anything>