简体   繁体   English

Wordpress htaccess来拒绝子文件夹上的子域

[英]Wordpress htaccess to redict subdomain on sub folder

My public html folder has 2 subfolders: ./en and ./fr . 我的公共html文件夹有2 ./en文件夹: ./en./fr
My main domain is .com domain, it currently lands in the root of public_html folder (I am using bluehost and the cPanel is opened with the mydomain.com as primary domain in this cPanel). 我的主要域是.com域,当前它位于public_html文件夹的根目录中(我正在使用bluehost,并且以mydomain.com作为此cPanel中的主域打开了cPanel)。
I have opened a subdomain fr.mydomain.com which I want my visitors to be redirect to the ./fr subfolder. 我打开了一个子域fr.mydomain.com,希望我的访问者重定向到./fr子文件夹。
I am using wordpress in ./en folder and another wordpress in ./fr folder. 我使用WordPress中./en文件夹和一个WordPress ./fr文件夹。
I want mydomain.com to fall into the ./en folder and fr.mydomain.com to fall into the ./fr folder. 我希望mydomain.com落入./en文件夹,而fr.mydomain.com落入./fr文件夹。

How should I setup .htaccess of the public root folder ? 我应该如何设置公共根文件夹的.htaccess?
How should I setup .htaccess of the /en folder ? 我应该如何设置/en文件夹的.htaccess?
How should I setup .htaccess of the /fr folder ? 我应该如何设置/fr文件夹的.htaccess?

You need to rewrite based on the HTTP Host . 您需要基于HTTP Host进行重写。

Try this: 尝试这个:

RewriteEngine On
RewriteCond %{HTTP_HOST} en.example.com
RewriteRule ^(.*)$ http://example.com/en/$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} fr.example.com
RewriteRule ^(.*)$ http://example.com/fr/$1 [L,NC,QSA]

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

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