我正在与mod_rewrite作战。我有以下两条规则都直接到example.com/products.php
(注意,每条规则的第1行只是为了强制执行尾随转发)
RewriteEngine on
RewriteBase /
#RULE 1
RewriteRule ^products$ /products/ [R]
RewriteRule ^products/$ products.php [L]
#RULE 2
RewriteRule ^products/hardware$ /products/hardware/ [R]
RewriteRule ^products/hardware/$ products.php [L]**
规则1旨在将/products/
映射到products.php
规则2旨在将/products/hardware/
映射到products.php
我的问题是规则1似乎工作正常,浏览器中显示的网址是example.com/products/
但是,当我在浏览器中输入example.com/products/hardware/
时,它会显示正确的页面,但网址会更改回example.com/products.php
(公开底层网址)
知道规则2导致显示基础URL的原因吗?
欢呼声
马克