reroute all subdomains to a particular subdomain?

Using a single web hosting account to host multiple sites

reroute all subdomains to a particular subdomain?

Postby mr_bungalow » Mon Feb 26, 2007 11:07 am

I've been trying to get this to work for the past two days and admit defeat.

We have a site where we need to keep track of where the user is coming from (i.e. www.site.com/entry1, www.site.com/entry2, www.site.com/entry3 which would redirect to www.site.com/home?cog=entry1¦entry2¦entry3).

We already have some mod_alias rules set up to point to the local directory. Is it possible to use mod_rewrite along with mod_alias?

Here is the relevant info from my config file:

Code: Select all
<IfModule mod_alias.c>
Alias /home "/home/foo/smart/static/"
</IfModule>


and here is where I am trying to redirect using mod_rewrite

Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_METHOD} TRACE
RewriteRule .* - [F]
RewriteRule ^/(entry1¦entry2¦entry3\.) /home [E=COG:$1]


This should in theory redirect to /home/foo/smart/static with an environment variable COG set to entry1, entry2, or entry3 right?
mr_bungalow
 
Posts: 2
Joined: Mon Feb 26, 2007 11:00 am

Postby richardk » Tue Feb 27, 2007 9:39 am

The mod_rewrite should be in the <Directory> for your document root. Then add the PT and L flags.
Code: Select all
[E=COG:$1,PT,L]


By the way, an environmental variable is not the same as a query string variable. You might want "/home?cog=$1" instead of "E=COG:$1,".
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 18 guests

cron