Redirect subdomain to URL like this?

Tommyhara

Verified User
Joined
Jul 25, 2014
Messages
155
Hello,

I want to redirect my subdomain to these 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 tried to use this code

Code:
RewriteCond %{HTTP_HOST} ^subfolder\.example.com\/(subfolder)?$
RewriteRule ^(.*)$ "https\:\/\/example\.com\/subfolder\/$1" [R=301,L]
But it didn't work.

Does any know any solutions for this?
 
Top