Article 6KXCN Apache rewrite problem

Apache rewrite problem

by
BluePukeko
from LinuxQuestions.org on (#6KXCN)
I'm having a lot of difficulty getting my head around the whole apache rewrite functionality.
What I basically want to achieve is to access the /etc/hosts or /etc/hostname file and extract the server name and then manipulate that so I can create a new file name that would be called with a Include directive.

On the surface it seems very straightforward, but either I'm missing something or I'm trying to use the wrong commands.

Assuming we use the /etc/hostname file then I'd get bpg169-HOST from the first line.

Then I should be able to create something like this:

<IfDefine HOSTNAME>
# Include virtual machine sites-enabled file(s) based on hostname
<If "%{ENV:HOSTNAME} == 'bpg169.HOST'">
# Directives specific to 120.138.17.169
IncludeOptional sites-enabled/bluehost/*.conf
IncludeOptional sites-enabled/bluepress/*.conf
IncludeOptional sites-enabled/bluewiki/*.conf
</If>
<ElseIf "%{ENV:HOSTNAME} == 'bpg-170-DATA'">
# Directives specific to 120.138.17.170
IncludeOptional sites-enabled/bluedata/*.conf
</ElseIf>
</IfDefine>
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments