root
/question
/pages
index.html
.htaccess
/root/.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/question
/question/.htaccess
RewriteEngine On
#RewriteBase /
RewriteRule ^question/are-bitcoin-gains-taxable/?$ /pages/questions/viewQuestion.php?id=9 [L]
所以我想做的是将我的 htaccess 分成目录,当前的设置正在产生/404 错误 /pages/questions/viewQuestion.php?
确实存在,我只是认为它不存在阅读第二个 .htaccess ,感谢您的帮助。
最佳答案
为此,您不需要 root .htaccess 中的任何内容,并且 RewriteCond
本身无论如何也不会执行任何操作。
您只需在 /question/.htaccess
中包含此规则
RewriteEngine On
RewriteRule ^are-bitcoin-gains-taxable/?$ /pages/questions/viewQuestion.php?id=9 [L,NC,QSA]
RewriteRule
中的 URI 路径相对于 .htaccess 所在的目录,因此此处不会匹配 question/
。
关于.htaccess - 目录问题的不同htaccess,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70805152/