我想要一个这样的网址:
domain.com/css/site.css?test=234
规则:
RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php
RewriteRule ^css/([a-zA-Z0-9]+).css?count=(.*)$ css.php?f=$1&test=$2
但我每次都得到404:未找到(site.css)
如果我有这样的规则它可以正常工作,只需要获得$ _GET-Variable:
RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php
RewriteRule ^css/([a-zA-Z0-9]+).css$ css.php?f=$1
答案 0 :(得分:2)
要在RelriteRule中匹配的URL中不存在查询字符串。你需要这样的东西:
RewriteEngine On
RewriteRule ^([a-z]+)/$ $1.php
RewriteCond %{QUERY_STRING} count=(.*)$
RewriteRule ^css/([a-zA-Z0-9]+).css$ css.php?f=$1&test=%1
您可以在此处详细了解RewriteCond
和RewriteRule
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond
您可以在此处查看RewriteConds和RewriteRules的执行顺序 http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#InternalRuleset