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

x
?
Solved

Apache working with conditions

Posted on 2010-09-10
1
Medium Priority
?
221 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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). #…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

971 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