我有一个基本的 htaccess 重写文件,但是当其中一个规则与之前的规则类似时,我无法使其工作。
我的代码是;
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gallery$ gallery.php
RewriteRule ^about-us/page-1$ page-1.php
RewriteRule ^about-us/page-2$ page-2.php
RewriteRule ^about-us$ about-us.php
图库、第 1 页和关于我们都可以使用,但第 2 页不行。
有办法让它发挥作用吗?
我尝试了不同的顺序,如果将“关于我们”放在第一位,则第 1 页或第 2 页都不起作用
注意:重定向重定向到 page-2,但包含的文件(css、js 等)不会加载
最佳答案
试试这个:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /about-us/page-2$
RewriteRule .* page-2.php [NC,L]
RewriteRule ^gallery$ gallery.php [NC,L]
RewriteRule ^about-us/page-1$ page-1.php [NC,L]
RewriteRule ^about-us$ about-us.php [NC,L]
关于php - htaccess 重写规则仅部分有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29866058/