Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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. www.domain.com rather than www.domain.com/some-page/) then i need to redirect them to a specific page within the site (i.e. anyone accessing domain.com might need to be sent to domain.com/special-landing-page/). 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 m-g-i.co.uk ServerAlias m-g-i.co.uk *.m-g-i.co.uk ServerAlias central-heating-nottingham.co.uk *.central-heating-nottingham.co.uk

    RewriteCond %{HTTP_HOST} ^(www.)?central-heating-nottingham.co.uk$ [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:

127.0.0.1 - - [15/Jun/2010:22:07:50 +0100] [m-g-i.co.uk/sid#84464a8][rid#8711c60/subreq] (1) pass through /

127.0.0.1 - - [15/Jun/2010:22:07:56 +0100] [m-g-i.co.uk/sid#84464a8][rid#870dc50/initial] (2) init rewrite engine with requested uri /favicon.ico

127.0.0.1 - - [15/Jun/2010:22:07:56 +0100] [m-g-i.co.uk/sid#84464a8][rid#870dc50/initial] (3) applying pattern '^$' to uri '/favicon.ico'

127.0.0.1 - - [15/Jun/2010:22:07:56 +0100] [m-g-i.co.uk/sid#84464a8][rid#870dc50/initial] (1) pass through /favicon.ico

127.0.0.1 - - [15/Jun/2010:22:07:56 +0100] [m-g-i.co.uk/sid#84464a8][rid#8713c68/subreq] (2) init rewrite engine with requested uri /favicon.ico

share|improve this question

1 Answer 1

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [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

 
discard

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