Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Mar 10, 2011 8:52 pm 
Offline
Junior Member
User avatar

Joined: Wed Oct 20, 2010 7:10 pm
Posts: 36
Location: Sebastopol, CA
I want to allow dynamic subdomains, and am trying to use a staging subdomain for testing.

I want to make the following work, without changing the web browser address bar.

Start with:
http://foo.www-staging.domain.tld/SomePage?name=val

Should become:
http://www-staging.domain.tld/SomePage? ... o&name=val

I have gotten the DNS set up to accomplish this, and have gotten the VirtualHost setup to serve correctly. My problem is figuring out the correct code in the .htaccess file. I have also tried using the ENV flag (e.g. [E=subdomain:%1]), but have had no success.

I have been able to get the above URL rewriting to work by forcing it in the browser, but all of my attempts to keep it under the covers of the browser address bar causes infinite rewriting.

Any suggestions?


Top
   
 Post subject:
PostPosted: Thu Mar 10, 2011 9:34 pm 
Offline
Senior Member
User avatar

Joined: Sun Aug 10, 2008 11:26 am
Posts: 104
Location: ~$
Do you have a RewriteCond checking if the HTTP hostname is www-staging.domain.tld, so that mod_rewrite doesn't loop?

Something like
Code:
RewriteCond %{HTTP_HOST} !^www-staging


Top
   
 Post subject:
PostPosted: Thu Mar 10, 2011 11:47 pm 
Offline
Junior Member
User avatar

Joined: Wed Oct 20, 2010 7:10 pm
Posts: 36
Location: Sebastopol, CA
Here is what I have so far, and your addition did not seem to help. I still am redirected.

Code:
RewriteCond %{HTTP_HOST} ^([^.]+)\.www-staging\.domain\.tld [NC]
RewriteRule ^(.*)$ http://www-staging.domain.tld/$1?subdomain=%1 [NS,QSA,E=subdomain:%1]


Top
   
 Post subject:
PostPosted: Fri Mar 11, 2011 9:52 am 
Offline
Senior Member
User avatar

Joined: Sun Aug 10, 2008 11:26 am
Posts: 104
Location: ~$
Whoops. I just re-read your question more carefully and realized you're rewriting internally, not doing a HTTP redirect, so my suggestion above is totally useless. Sorry.

Have you tried doing something like
Code:
RewriteCond %{QUERY_STRING} !subdomain=
?

Edit: Reading your second post, it seems like you are doing a HTTP redirect (the external URL in your RewriteRule). Is this what you want to do?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group