not rewriting silently

Using a single web hosting account to host multiple sites

not rewriting silently

Postby clive » Sat Oct 03, 2009 9:52 pm

I have a rewrite rule that works ok but does not do it silently.

RewriteCond %{http_host} ^([a-z]+)\.mysite\.com
RewriteCond %1 !=www [NC]
RewriteRule ^([a-z]+)(/(.*))?$ http://www.mysite.com/$3?lang=$1 [L]

This alters the subdomain to the main domain and tags the sub domain as a query string ok but it shows the new url in the browser. Is there any way that I can get it tp keep the old url. :o
clive
 
Posts: 5
Joined: Thu Oct 01, 2009 8:54 pm
Location: France

Re: not rewriting silently

Postby DanielStutzbach » Sun Oct 04, 2009 6:46 am

clive wrote:This alters the subdomain to the main domain and tags the sub domain as a query string ok but it shows the new url in the browser. Is there any way that I can get it tp keep the old url. :o


Not with mod_rewrite (which tells the user's browser to go to a different URL, which will always be displayed). Maybe Virtual Hosts can help you? That's what I would use.
DanielStutzbach
 
Posts: 6
Joined: Wed Aug 19, 2009 6:49 am

Postby richardk » Sun Oct 04, 2009 7:29 am

I have a rewrite rule that works ok but does not do it silently.

Including http://... in the RewriteRule substitution causes the redirect.

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$ [NC]
RewriteCond %1 !=www [NC]
RewriteRule ^([a-z]+)(/(.*))?$ http://www.mysite.com/$3?lang=$1 [L]

I presume the sub domain requests go to your main document root.

If the sub domain is the language code, you could have en.example.com/file instead of en.example.com/en/file with
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$ [NC]
RewriteCond %1 !=www [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1?lang=%1 [L]


Not with mod_rewrite (which tells the user's browser to go to a different URL, which will always be displayed). Maybe Virtual Hosts can help you? That's what I would use.

FAQ: Virtual sub domains.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests

cron