Solved

rewritecond if is serveralias

Posted on 2009-07-16
11
817 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:soyglobal
11 Comments
 
LVL 42

Expert Comment

by:David S.
ID: 24867239
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

0
 
LVL 14

Accepted Solution

by:
flob9 earned 500 total points
ID: 24867251
Something like this :

RewriteCond %{HTTP_HOST}   !^www\.mydomain\.com [NC]
RewriteRule ^/(.*)         http://mydomain.com/$1 [L,R]

0
 

Author Comment

by:soyglobal
ID: 24867310
I know this way, but the problem is that rule not apply to all server alias,
0
 
LVL 14

Expert Comment

by:flob9
ID: 24867381
Where do you add this rule ? .htaccess file or apache configuration ?
0
 

Author Comment

by:soyglobal
ID: 24867534
Apache configuration in virtualhost
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Expert Comment

by:flob9
ID: 24867548
perhaps your rewrite rule is overriden by a .htaccess file
0
 

Author Comment

by:soyglobal
ID: 24867711
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
0
 
LVL 14

Expert Comment

by:flob9
ID: 24867866
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
0
 

Author Comment

by:soyglobal
ID: 24870074
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
0
 
LVL 27

Expert Comment

by:caterham_www
ID: 24873021
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.
0
 

Author Comment

by:soyglobal
ID: 24873100
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
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A step by step SEO guide to creating content that drives traffic and maximizes page views by using the right tricks, tools and keyword analysis. You are the subject matter expert.   You have forgotten more about your area of expertise than most …
Your personal information, where you live, your wedding information, and anything else personal may be located online and in many cases the aggregators who pulled this stuff did so without your permission. Here are ways that you can get rid of unwan…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now