更新时间:2023-02-24 10:59:26
匹配第二个规则的网址也将匹配的第一个规则。作为第一个规则被标记为L时,第二条规则将永远不会被施加
URLs that match the second rule will also match the first rule. As the first rule is marked "L", the second rule will never be applied.
也许你应该匹配绝对URL - 以正则表达式^ /
来匹配URL的开头,并以 $ 系铃人code>到URL的末尾匹配。请记住,重写规则应用于URL路径(所有在它后面website.com,包括斜线)。
Maybe you should match absolute URLs - begin the regex with ^/
to match the beginning of a URL, and end it with $
to match the end of the URL. Remember that rewrite rules are applied to the URL path (everything that follows website.com, including the slash).
例如(没有测试这门课程的):
For example (didn't test this of course):
# Example: website.com/books.php -> website.com/index.php?com=cat&catname=books
RewriteRule ^/([^/]+).php$ /index.php?com=cat&catname=$1 [L]
# Example: website.com/books/java.php -> website.com/index.php?com=detail&catname=books&prodname=java
RewriteRule ^/([^/]+)/([^/]+).php$ /index.php?com=detail&catname=$1prodname=$2 [L]