Link to home
Start Free TrialLog in
Avatar of soyglobal
soyglobal

asked on

rewritecond if is serveralias

Hi, i want do a rewrite in apache that the unique condition if the host is one of the different serveralias (more than 90 domains).
How i can do it without use a rewritecond line per each domain.

Thanks
Avatar of David S.
David S.
Flag of United States of America image

You can check if the hostname is not one of the ones you don't want to perform the rewrite for. Something like this:
RewriteCond %{HTTP_HOST} !www.primaryhost.com$

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of flob9
flob9
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soyglobal
soyglobal

ASKER

I know this way, but the problem is that rule not apply to all server alias,
Where do you add this rule ? .htaccess file or apache configuration ?
Apache configuration in virtualhost
perhaps your rewrite rule is overriden by a .htaccess file
the problem not is that rewrite failed, my problem is how manage a rewritecond with near 75 conditionals
rewritecond  %{HTTP_HOST}= domain1 or
rewritecond  %{HTTP_HOST}= domain2 or
....
rewritecond  %{HTTP_HOST}= domain75 or
rewrite from / to the moon.foo
I think apache should has a way for do it more simple and fast
What exactly do you want ? give us some samples.

foo.bar.com => www.bar.com  ?
bla.bla.com => bla.com ? ...

You can certainly achieve this with some regex
I need some this:
if http_host = one of 75 group1 alias domain go to www.foo.com
if http_hots = one of 20 group2 alias domain go to www.blaba.com
the problem is the number of values to check (75 and 20), and increasing per month
What about using 4 different <virtualhost *:80> sections? One for www.foo.com, one for www.blaba.com,  one for aliases of www.foo.com and one for aliases of www.blaba.com; while you put a simple

Redirect 301 / http://www.foo.com

into the "alias" <virtualhost >'s instead of brothering with mod_rewrite.
because i don't want do a redirect, i need have as i put before
rewrite on
rewritecon http-referrer = one of group1 alias
rewriteurl (.)*  http://bkjkj.com/?redirect-host=http-referrer qsa, l

rewritecon http-referrer = one of group2 alias
rewriteurl (.)*  http://app.foo.com/?redirect-host=http-host qsa, l