Rewrite from subdomain to subfolder
3 posts
• Page 1 of 1
Rewrite from subdomain to subfolder
We currently have a set up that works and we are splitting things up via subdomain.
www.xyz.com
br.xyz.com
ca.xyz.com
similarily on product pages we have:
www.xyz.com/product-page.asp
br.xyz.com/product-page.asp
ca.xyz.com/product-page.asp
We then have a rewrite that goes like this:
RewriteRule product$ /product-page.asp [NC,L,QSA]
what I want to do is take the existing subdomain and re-write it as a subfolder and so hence if after the re-write above, someone where to visit:
www.xyz.com/br/product
They would get the same result as visiting: br.xyz.com/product
So hence all three of these would produce the same result
br.xyz.com/product-page.asp
br.xyz.com/product
www.xyz.com/br/product
Can anyone please help me with this... I have the following but it doesnt seem to work:
RewriteRule ^br/(.*)$ http://br.xyz.com/(.*) [NC,L,QSA]
www.xyz.com
br.xyz.com
ca.xyz.com
similarily on product pages we have:
www.xyz.com/product-page.asp
br.xyz.com/product-page.asp
ca.xyz.com/product-page.asp
We then have a rewrite that goes like this:
RewriteRule product$ /product-page.asp [NC,L,QSA]
what I want to do is take the existing subdomain and re-write it as a subfolder and so hence if after the re-write above, someone where to visit:
www.xyz.com/br/product
They would get the same result as visiting: br.xyz.com/product
So hence all three of these would produce the same result
br.xyz.com/product-page.asp
br.xyz.com/product
www.xyz.com/br/product
Can anyone please help me with this... I have the following but it doesnt seem to work:
RewriteRule ^br/(.*)$ http://br.xyz.com/(.*) [NC,L,QSA]
Re: Rewrite from subdomain to subfolder
As an alternative, I thought I could do something such as:
RewriteRule ^/(.*)/$ /(.*) [NC,L,QSA]
Then I was going to look for the first 4 letters in the query and do something accordingly as such it would be
http://www.xyz.com/br/somepage
This would essentailly trandlaste to http://www.xyz.com/somepage
However I would grab the /*whatevercountry*/ (subfolder) and show the appropriate content but this method doesnt seem to work either.
RewriteRule ^/(.*)/$ /(.*) [NC,L,QSA]
Then I was going to look for the first 4 letters in the query and do something accordingly as such it would be
http://www.xyz.com/br/somepage
This would essentailly trandlaste to http://www.xyz.com/somepage
However I would grab the /*whatevercountry*/ (subfolder) and show the appropriate content but this method doesnt seem to work either.
Re: Rewrite from subdomain to subfolder
Hello.
To tell exact syntax I need to see your complete .htaccess, however, please try this rule:
To tell exact syntax I need to see your complete .htaccess, however, please try this rule:
- Code: Select all
RewriteCond %{HTTP_HOST} (?!www\.)(\w+)\.xyz\.com [NC]
RewriteRule (.*) /%1/$1
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests