LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-07-2024, 03:41 PM   #1
BluePukeko
LQ Newbie
 
Registered: Mar 2024
Posts: 5

Rep: Reputation: 0
Apache rewrite problem


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>
 
Old 04-08-2024, 02:22 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

I would create a kind of template and a shell script. First remplace bpg169.HOST with some word- like ReplaceHostName. Save it as a template file. Then:
Code:
host=$(cat /etc/hostname)
cat template.conf | sed "s/ReplaceHostName/$host/g" > includefile.conf
 
  


Reply

Tags
apache, ubuntu



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
proxy problem use apache rewrite rules xiutuo Linux - Server 2 04-19-2013 01:48 AM
[SOLVED] apache rewrite proxy problem deesto Linux - Server 3 10-26-2011 10:00 AM
apache proxy with rewrite problem xiutuo Linux - Server 3 12-01-2010 05:56 AM
apache rewrite F problem xiutuo Linux - Server 3 09-10-2009 10:48 PM
Problem with Apache rewrite griffey Linux - Software 1 08-10-2007 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration