Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

rewritecond if is serveralias

Posted on 2009-07-16
11
Medium Priority
?
843 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 43

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 2000 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What You Need to Know when Searching for a Webhost Provider
There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
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…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

972 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