繁体   English   中英

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

[英]How to make different htaccess rewrite rules for root and for a subfolder?

我有这样的目录结构:

root
root/en

我的根目录中有一个.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]

这使SEO友好的URL。 (show_article.php生成html输出,但URL像这样:root / title_of_the_article)

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

现在,使用我的.htaccess,输出为:

root/title -> root/title
root/en/title -> root/title

因此,我需要对.htaccess进行修饰,使其像这样工作:

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]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM