Home Wordpress htaccess to redict subdomain on sub folder
Reply: 1

Wordpress htaccess to redict subdomain on sub folder

user92481
1#
user92481 Published in 2017-12-04 12:42:00Z

My public html folder has 2 subfolders: ./en and ./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).
I have opened a subdomain fr.mydomain.com which I want my visitors to be redirect to the ./fr subfolder.
I am using wordpress in ./en folder and another wordpress in ./fr folder.
I want mydomain.com to fall into the ./en folder and fr.mydomain.com to fall into the ./fr folder.

How should I setup .htaccess of the public root folder ?
How should I setup .htaccess of the /en folder ?
How should I setup .htaccess of the /fr folder ?

Luke Taylor
2#
Luke Taylor Reply to 2017-12-04 12:55:42Z

You need to rewrite based on the 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]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31523 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO