Solved

Apache working with conditions

Posted on 2010-09-10
1
215 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
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
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…

810 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