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:
Latest Threads
Replies
0
Views
115
Replies
0
Views
65
Replies
0
Views
57
Replies
1
Views
87
Recommended Threads
Replies
3
Views
3,115
Replies
16
Views
5,794
Replies
8
Views
6,098

Latest postsNew threads

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