1

我正在与 mod_rewrite 作斗争。我有以下两条规则都直接指向 example.com/products.php

(注意每条规则的第一行只是强制执行尾部正斜杠)

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 似乎工作正常,浏览器中显示的 URL 是example.com/products/ 但是当我进入example.com/products/hardware/浏览器时,它显示正确的页面但 URL 变回example.com/products.php(暴露底层 url)

知道为什么规则 2 会导致显示基础 URL 吗?

干杯

标记

4

0 回答 0