Apache 如何使.htaccess规则不被覆盖?
我的.htaccess:Apache 如何使.htaccess规则不被覆盖?,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我的.htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^product-([^/]+).html$ index.php?tid=$1 [L] RewriteRule ^links-([^/]+).html$ index.php?page=links&lid=$1 [L] RewriteRule ^([^/]+)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^product-([^/]+).html$ index.php?tid=$1 [L]
RewriteRule ^links-([^/]+).html$ index.php?page=links&lid=$1 [L]
RewriteRule ^([^/]+).html$ index.php?page=$1 [L]
问题:
如果我把它放到主站点目录文件test.html
中,它就不可见了
如果我更改htaccess文件规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+).html$ index.php?page=$1 [L]
RewriteRule ^product-([^/]+).html$ index.php?tid=$1 [L]
RewriteRule ^links-([^/]+).html$ index.php?page=links&lid=$1 [L]
我在url/product-10.html
中有404错误,但是test.html
可用
如何在这两种情况下都有效(test.html必须可用,如果存在,product-10.html必须重定向到index.php?tid=10)?首先在单独的规则中忽略所有实际文件和目录 使用此代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^product-([^/]+)\.html$ index.php?tid=$1 [L,QSA]
RewriteRule ^links-([^/]+)\.html$ index.php?page=links&lid=$1 [L,QSA]
RewriteRule ^([^/]+)\.html$ index.php?page=$1 [L,QSA]
很高兴知道,您可以点击我答案左上角的勾号,将答案标记为已接受。