2014-10-16 51 views
0

我想要做的URL与mod_rewrite的这样的重写URL:如何重写在Apache的具体路径参数

example.com/path/foo/rest_of_path-> example.com/path/rest_of_path (remove foo) 
example.com/path/bar/rest_of_path-> example.com/path/rest_of_path (remove bar) 
example.com/path/sample/rest_of_path-> no rewriting<br/> 
example.com/path/test/rest_of_path-> no rewriting 

酒吧是动态 测试样品是静态的,我有路径列表。

所以我认为做这样的(在我的httpd.conf):

RewriteCond ....... #it's here i'm blocking, how write only if $1 in test,sample ? 
RewriteRule ^path/(.\*)/(.*)$ /path/$2 

回答

0
# You can add as much RewriteCond as you need to exclude static words 
RewriteCond %{REQUEST_URI} !^/path/sample/.* 
RewriteCond %{REQUEST_URI} !^/path/test/.* 
RewriteRule ^path/(.*)/(.*) /path/$2 
+0

谢谢 但它错过[OR]标志: 的RewriteCond%{REQUEST_URI}! ^/path/sample /.* [OR] RewriteCond%{REQUEST_URI}!^/path/test /.* – 2014-10-17 09:11:53

+0

不,您不需要[或]但是(隐含的)。只有在路径中没有静态字样和没有静态字测试的情况下,才需要应用RewriteRule。或者我误解了你? – 2014-10-17 09:25:03

+0

是的,你说得对, 谢谢 – 2014-10-17 12:14:18