Page 1 of 1

if I could send the servername to the rewrite rule

Posted: Fri Jun 08, 2012 5:51 pm
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]

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

Posted: Sat Jun 09, 2012 12:18 am
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.