iLinux85
iLinux85

Reputation: 387

Redirect Subdomain To another subfolder same structure

I want to know how to redirect subdomain to another subfolder with same structure by .htaccess

for example i want to redirect

bookmarks.site.com

to

www.site.com/bookmarks

and if someone go to link

http://bookmarks.site.com/story.php?title=free-logo-design

it will redirect it to

http://www.site.com/bookmarks/story.php?title=free-logo-design

thanks

Upvotes: 0

Views: 343

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

Try putting this in the htaccess file in your document root:

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

Upvotes: 1

Related Questions