Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 如何使.htaccess规则不被覆盖?_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 如何使.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 ^([^/]+)

我的.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 ^([^/]+).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]

很高兴知道,您可以点击我答案左上角的勾号,将答案标记为已接受。