[英]How to make different htaccess rewrite rules for root and for a subfolder?
I have a directory structure like this: 我有这样的目录结构:
root
root/en
I have a .htaccess in the root: 我的根目录中有一个.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]
This makes SEO friendly URLs. 这使SEO友好的URL。 (show_article.php generates the html output, but the URL is like this: root/title_of_the_article) (show_article.php生成html输出,但URL像这样:root / title_of_the_article)
I'd like to clone the whole website into the root/en directory. 我想将整个网站克隆到root / en目录中。
Now, with my .htaccess the output is this: 现在,使用我的.htaccess,输出为:
root/title -> root/title
root/en/title -> root/title
So I need to moodify my .htaccess to work like this: 因此,我需要对.htaccess进行修饰,使其像这样工作:
root/title -> root/title
root/en/title -> root/en/title
I don't know how to do this, I tried several things today, but without any success. 我不知道该怎么做,我今天尝试了几件事,但没有成功。 Please help! 请帮忙!
You can keep this code in both /.htaccess
and /en/.htaccess
: 您可以将此代码保存在/.htaccess
和/en/.htaccess
:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ show_article.php?q=$1 [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.