if I could send the servername to the rewrite rule

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

if I could send the servername to the rewrite rule

Post by rhecker »

I have a group of websites as subwebs in an account. They share a common code base, I use aliases so they can share CSS files, etc., and I would like them to share a set of rewrite rules (which create 'clean' urls).

Problem is, if I put the code in a htaccess file in the document root of the individual websites, all works fine, but if I put the htaccess file above that (or put them in http.conf), where they can share it, the rules seem confused regarding the appropriate document root, and I get messages like: "The requested URL /page/67/ was not found on this server."

This is not an issue of the rules applying but the page being confused about the location of css files, etc. This is an issue of the rules either not applying at all or referring to an inappropriate location on the server.

It's pretty important that I not have to manage a htaccess file in each subweb. Any ideas on how to resolve this? I will post the rules:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([0-9_-]+)/([0-9_-]+)/$ index.php?page_id=$1&language_id=$2 [NC,L]
RewriteRule ^([0-9_-]+)/?$ index.php?page_id=$1 [NC,L]
RewriteRule course/([0-9_-]+)$ index.php?course_id=$1 [NC,L]
RewriteRule program/([a-zA-Z0-9_-]+)$ index.php?url_keyword=$1 [NC,L]
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: if I could send the servername to the rewrite rule

Post by requinix »

Since you have access to the virtual host configuration you can add Includes to them. Stick the common rules in a file somewhere and

Code: Select all

<Directory /path/to/subweb>
    Include /path/to/file
</Directory>
in each VirtualHost (which probably has a Directory already in it).

Untested but I think that will work. At the very least it's valid.
Post Reply