Reputation:
I am trying to redirect http://[random-string].domain.com/ to http://domain.com/folder/[random-string]/
I currently have this:
RewriteCond %{HTTP_HOST} ^.*\.domain\.com
RewriteRule ^.*$ http://domain.com/folder/$1/ [R=301,L]
It currently points to http://domain.com/folder//. (The $1 is missing) How do I fix this?
Upvotes: 2
Views: 2153
Reputation: 133
how i fix it? my subdomain not is randomically have where the replace for $1 ? cheers
RewriteCond %{HTTP_HOST} ^(.).domain.com RewriteRule ^(.)$ http://domain.com/folder/%1/$1 [R=301,L]
Upvotes: 0
Reputation: 13438
You need to use parenthesis to grab the value matched, in your case:
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/folder/%1/$1 [R=301,L]
assuming you also want to redirect http://[random-string].domain.com/something to http://domain.com/folder/[random-string]/something
Upvotes: 3