简体   繁体   中英

htaccess code for redirecting sub folder to the root domain without affecting other sub domain

The issue is in my public_html directory I have a www7 folder, which I used as a root domain link. Like if anyone visit example.com or www.example.com it redirects it to www7.example.com . For this I have used this below htaccess code:

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/www7\.example\.com\/" [R=301,L]

I also have many other sub domains under public_html like, sub1.exaple.com , sub2.exaple.com . Now I want that tough my main files are present in www7 folder, whenever anyone open exaple.com it will actually openup the files inside www7 folder, but have to make sure that the other sub domains under public html should not get affected. Also in the www7 folder a wordpress site has been hosted, so it needs to be wordpress friendly too. Also if anybody open www.exaple.com it will redirect him to exaple.com . I think for this, the below code will work

RewriteCond %{HTTP_HOST} ^www\.mynewwebsite\.com$ [NC]
RewriteRule ^(.*)$ http://mynewwebsite.com/$1 [L,R=301]

But not sure about the directory issue. Please help.

You have this rule in root .htaccess:

RewriteCond %{HTTP_HOST} ^isaumya\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.isaumya\.com$
RewriteRule ^/?$ "http\:\/\/www8\.isaumya\.com\/" [R=301,L]

Replace this rule with:

RewriteRule !^www8/ /www8%{REQUEST_URI} [L,NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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