Php 如何为根目录和子文件夹制定不同的htaccess重写规则?

Php 如何为根目录和子文件夹制定不同的htaccess重写规则?,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我的目录结构如下: root root/en root/title -> root/title root/en/title -> root/en/title 我在根目录中有一个.htaccess: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !favicon\.ico [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FI

我的目录结构如下:

root
root/en
root/title -> root/title
root/en/title -> root/en/title
我在根目录中有一个.htaccess:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !favicon\.ico  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ show_article.php?q=$1 [QSA]
这使得搜索引擎优化友好的网址。 (show_article.php生成html输出,但URL如下:文章的root/title_)

我想将整个网站克隆到root/en目录中

现在,使用my.htaccess,输出如下:

root/title -> root/title
root/en/title -> root/title
因此,我需要对我的.htaccess进行moodify,以便像这样工作:

root
root/en
root/title -> root/title
root/en/title -> root/en/title
我不知道怎么做,今天我尝试了几件事,但都没有成功。
请帮忙

您可以将此代码保存在
/.htaccess
/en/.htaccess
中:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ show_article.php?q=$1 [QSA,L]

我的问题是,根目录中的.htaccess似乎覆盖了en/目录中的。没有根目录。htaccess从不覆盖子目录中的。当前目录的.htaccess始终优先。
show\u article.php
是否同时存在于
en
和root中?如何测试它?是的,show_article.php存在于两个目录中。测试很简单,我键入serverurl/en/title,得到的serverurl/title不带“en”。如果浏览器中的URL正在更改,则您有一些其他规则/代码导致此情况,因为此规则没有执行任何URL重定向