Apache Rewrite条件 - 任何想法?

时间:2011-05-25 01:26:31

标签: mod-rewrite

<VirtualHost _default_:80>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
</IfModule>

</VirtualHost>

这会将整个请求uri更改为小写。我希望这发生在特定的文件夹(/css),但RewriteMap在.htaccess中不起作用。我是regex和Rewrite的新手。我需要一个RewriteCond,只检查/css/<any subfolder> and/or <files>.是否有任何身体帮助?

编辑:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteCond %{REQUEST_URI} ^/css/
RewriteRule (.*) ${lc:$1} [R=301,L]
</IfModule>

这似乎适用于特定文件夹 - /css/。不确定这是否是万无一失的

</VirtualHost>

1 个答案:

答案 0 :(得分:0)

^ / CSS /

  

CondPattern是perl兼容的正则表达式

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond

  

RewriteCond%{REQUEST_URI} ^ / css /