.htaccess - 目录问题的不同htaccess

标签 .htaccess

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/

相关文章:

php - Htaccess 替换 WordPress 中的 URL 片段?

php - 如何使用 .htaccess 仅允许对特定目录的相同域请求?

apache - 如何避免在 url 上输入 .php?

perl - 确认搜索 .htaccess 或其他点文件

php - 我如何使用 .htaccess 重定向像 (https ://example. com/digital-marketing.php/ercbierubcrei) 这样的非结构化链接?

regex - Drupal URL重写冲突

php - 将 HTML 作为 PHP 执行

wordpress - htaccess 将domain2.com重定向到domain1.com/specific-page的 final方法

html - 未声明语言 理想情况下

regex - 测试 .htaccess 文件的更好方法