Reputation: 4904
Please help me to create rewrite rule for wordpress
(.htacess) that will do the following:
Redirect subdomain
AAA.site.com/BBB.html to site.com/AAA/BBB.html
Let me explain here
I have more than 100+ subdomains which i want to redirect to the "folder" with same name as subdomain using WILDCARD.
Thanks in advance
Upvotes: 0
Views: 1822
Reputation: 1
I tried the selected solution, but it did not work for me. If it also didnt work for you try this
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com//%1/$1
This should work for any sub-domain, just change example.com to your website name.
Upvotes: -1
Reputation: 1124
I think, this is what you are looking for:
RewriteCond %{HTTP_HOST} ^subdomain\.yourwebsite\.com$
RewriteCond %{REQUEST_URI} !^/subdomain_folder/
RewriteRule (.*) /subdomain_folder/$1
Upvotes: 0
Reputation: 3923
Try this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^\(.*\)\.site\.com$ [NC]
RewriteRule ^(.*)$ http://site.com/\1/$1 [L,R=301]
Upvotes: 3
Reputation: 917
You can use mod_rewrite inside your .htaccess to do this.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^aaa\.site\.com$ [NC]
RewriteRule ^(.*)$ http://site.com/aaa/$1 [L,R=301]
Upvotes: 0