Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a client that now wants to point a couple of dozen urls to their main site. I have added them as serveralias's in the sites apache config file... so now all of these urls point to the primary one... excellent.

The problem i have is that if ANY of these alias's are accessed at the root (i.e. rather than then i need to redirect them to a specific page within the site (i.e. anyone accessing might need to be sent to However, any visit to anything other than the landing page should just continue as normal without any re-directs.

I've been battling with this for a few hours and can't seem to find the best solution. Does anyone have any suggestions?

EDIT: Ah i was actually doing that.. but couldnt get it to work. Any comments:

ServerName ServerAlias * ServerAlias *

    RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
    RewriteRule ^$ /nottingham [R,L]

DocumentRoot /home/ben/sites/mgi/releases/current/mgi

    WSGIScriptAlias and other WSGI stuff....

Update: I am getting the following output in the log...

I am getting the following output: - - [15/Jun/2010:22:07:50 +0100] [][rid#8711c60/subreq] (1) pass through / - - [15/Jun/2010:22:07:56 +0100] [][rid#870dc50/initial] (2) init rewrite engine with requested uri /favicon.ico - - [15/Jun/2010:22:07:56 +0100] [][rid#870dc50/initial] (3) applying pattern '^$' to uri '/favicon.ico' - - [15/Jun/2010:22:07:56 +0100] [][rid#870dc50/initial] (1) pass through /favicon.ico - - [15/Jun/2010:22:07:56 +0100] [][rid#8713c68/subreq] (2) init rewrite engine with requested uri /favicon.ico

share|improve this question

1 Answer 1

RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
RewriteRule ^$ /special-landing-page [R,L]

post what you've tried.

Use the following in the config file to generate a rewrite log to see just what is happening

RewriteLogLevel 9
RewriteLog /tmp/rl

Disable this afterwards as it can be quite server intensive on a busy site.

share|improve this answer
any particular reason you can't just use separate VirtualHost configs for each domain? Not enough of that log to see what isn't working. Can you snip the logs from a failed redirect? Should favicon have also been rewritten? – user6738237482 Jun 15 '10 at 23:15
I can add them to seperate virtualhost configs, and i'd happily do that but would that mean that i would have to create a seperate wsgi process for each one or is there a way to share across all domains? Secondly, i would still have the issue that if accessing the url root i need to redirect the user to a particular sub-path. I'm really stuck on this :( – Benjamin Dell Jun 17 '10 at 10:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.