Solved

Apache working with conditions

Posted on 2010-09-10
1
218 Views
Last Modified: 2012-05-10
hi!

i've got a little problem, trying touse different rewrite rules files from inside virtual host directive.

My virtual host is listening at *:80, and ServerName is aa.lalala.com. Alternatively, i've got several ServerAlias like bb.lalala.com and cc.lalala.com. I need some way to load every rewrite rules file for every subdomain and i'm thinking if there exists any kind of "if" directive in apache to load a rewrite file based on host.

For ex.: if arrives a request for aa.lalala.com use rewrite_rules_aaa.txt, if request id for bb.lalala.com use another one, etc.

Any way for doing this exists? I've seen SetEnvIf Directive, but i'm not ensure if this is i'm looking for.

Thanks in advance!
0
Comment
Question by:morsa804tons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
arober11 earned 500 total points
ID: 33648964
Yes, can think of a couple be the easiest is probably using mod_rewrite itself, and the SKIP [S] directive e.g.

# If NOT host aa.lalala.com, skip the next 20 rewrite rules.
RewriteCond %{HTTP_HOST}   !^aa.lalala.com$  [NC]
RewriteRule  .*  -  [S=20]

RewriteRule  .....


# If NOT host bb.lalala.com, skip the next 11 rewrite rules.
RewriteCond %{HTTP_HOST}   !^bb.lalala.com$  [NC]
RewriteRule  .*  -  [S=11]


RewriteRule  .....

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

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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