Subdomain redirection in htaccess?

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
520
Points
28
What codes in htaccess file to use to redirect type of thee URL

Code:
https://subfolder.example.com  --->  https://example.com/subfolder/
https://subfolder.example.com/subfolder/  --->  https://example.com/subfolder/
https://subfolder.example.com/subfolder/my-wordpress-post-title/  --->  https://example.com/subfolder/my-wordpress-post-title/
I am using this code
Code:
RewriteCond %{HTTP_HOST} ^subfolder\.example.com\/(subfolder)?$
RewriteRule ^(.*)$ "https\:\/\/example\.com\/subfolder\/$1" [R=301,L]
but it didn't work. Any help?
 

HostechSupport

Active member
Registered
Joined
Jan 19, 2013
Messages
68
Points
8
Say for instance, have a blog on the sub domain blog.abc.com, and you want to move it to the main domain www.abc.com. You can change your subdomain and main domain name accordingly.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.abc\.com [NC]
RewriteRule ^(.*) https://www.abc.com/$1 [L,R=301]

hope this helps :)
 
Last edited:
Recommended Threads
Replies
0
Views
2,241
Replies
4
Views
1,944
Replies
20
Views
7,091
Replies
3
Views
3,157

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top