Solved

rewritecond if is serveralias

Posted on 2009-07-16
11
823 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
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…

828 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