You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marko Hrastovec <ma...@hal.si> on 2007/08/15 22:44:59 UTC
[users@httpd] mod_vhost_alias and mod_rewrite working together
Hi!
I filed in the bug report number 43128
(http://issues.apache.org/bugzilla/show_bug.cgi?id=43128) and I was
redirected to this list to get help although I still think this is bug
and
should be fixed.
Here is what bothers me.
We are using rewrite rules on PHP sites to simulate user friendly urls.
We
have many developers who are programming the same site maintained by
subversion. Every programmer checks out the site to her/his home
directory. If
we put "*.hostname IN A x.x.x.x" in the DNS server, every programmer
could
have accessed his copy of the site via http://<username>.hostname.local/
just
by following the rule to check out the site to proper directoy.
VirtualDocumentRoot would enable every programmer to see his own copy.
Rewrite
rules would enable every programmer to simulate exactly the same
behavior for
user friendly URLs as on the main site.
Since mod_vhost_alias and mod_rewrite don't work together I have to
invent
some additional rules to simulate VirtualDocumentRoot along with rewrite
rules
which are already present. That way I have to have some very special
rewrite
rules applicable only for development copies and have to take special
care
that rules on the production server will work to. If I could use
directives
from both modules it would be much easier. That does not provide the
functionality to have the same configuration on development and
production
servers. This is always potential problem for compatibility.
Here is the example of the VirtualHost I was trying to setup. It is IP
based
virtual hosting:
<VirtualHost x.x.x.x>
VirtualDocumentRoot /home/%1/phpprojects/hostname/
ServerName hostname
CookieTracking on
AddType application/x-httpd-php .php
CustomLog logs/hostname.local.hal.si-combined_log combined
RewriteEngine on
RewriteRule ^/attachment/ /attachment.php [NC,L]
RewriteCond %{REQUEST_URI} ^(?!/images/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/img/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/script/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/rss/).* [NC]
RewriteCond %{QUERY_STRING} (.*) [NC]
RewriteRule ^/(.*?)(/(\d+))?$ /index.php?ID=$3&url=$1&%1 [NC,L]
<VirtualHost>
Possible workarounds I see now are to make a VirtualHost for every
developer
on the site with fixed DocumentRoot and rewrite rules as they will be on
the
production site. The second option is to make additional rewrite rules
which
are not going to be applied on the production server. The third option
is my
favorite and that is to use mod_vhost_alias and mod_rewrite together.
I think mod_vhost_alias should return the proper document root. If I
turn on
the Rewrite Rules the document root for virtualHost is /var/www/html
which is
the document root set up in httpd.conf as the document root for the
default site.
If I switch of the rewrite rules I get the proper document root.
Does anybody have some idea what would be the simplest and easiest
workaround?
Any suggestions are welcome. Thanks!
Marko
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] mod_vhost_alias and mod_rewrite working together
Posted by Marko Hrastovec <ma...@hal.si>.
I have solved the problem myself. It was again not reading the manuals
precisely enough. PT option to RewriteRule does the trick.
Sorry to have trashing the mailing list with problem I should have
solved by myself.
Marko
-----Original Message-----
From: Marko Hrastovec [mailto:marko.hrastovec@hal.si]
Sent: Wednesday, August 15, 2007 10:45 PM
To: users@httpd.apache.org
Subject: [users@httpd] mod_vhost_alias and mod_rewrite working together
Hi!
I filed in the bug report number 43128
(http://issues.apache.org/bugzilla/show_bug.cgi?id=43128) and I was
redirected to this list to get help although I still think this is bug
and
should be fixed.
Here is what bothers me.
We are using rewrite rules on PHP sites to simulate user friendly urls.
We
have many developers who are programming the same site maintained by
subversion. Every programmer checks out the site to her/his home
directory. If
we put "*.hostname IN A x.x.x.x" in the DNS server, every programmer
could
have accessed his copy of the site via http://<username>.hostname.local/
just
by following the rule to check out the site to proper directoy.
VirtualDocumentRoot would enable every programmer to see his own copy.
Rewrite
rules would enable every programmer to simulate exactly the same
behavior for
user friendly URLs as on the main site.
Since mod_vhost_alias and mod_rewrite don't work together I have to
invent
some additional rules to simulate VirtualDocumentRoot along with rewrite
rules
which are already present. That way I have to have some very special
rewrite
rules applicable only for development copies and have to take special
care
that rules on the production server will work to. If I could use
directives
from both modules it would be much easier. That does not provide the
functionality to have the same configuration on development and
production
servers. This is always potential problem for compatibility.
Here is the example of the VirtualHost I was trying to setup. It is IP
based
virtual hosting:
<VirtualHost x.x.x.x>
VirtualDocumentRoot /home/%1/phpprojects/hostname/
ServerName hostname
CookieTracking on
AddType application/x-httpd-php .php
CustomLog logs/hostname.local.hal.si-combined_log combined
RewriteEngine on
RewriteRule ^/attachment/ /attachment.php [NC,L]
RewriteCond %{REQUEST_URI} ^(?!/images/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/img/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/script/).* [NC]
RewriteCond %{REQUEST_URI} ^(?!/rss/).* [NC]
RewriteCond %{QUERY_STRING} (.*) [NC]
RewriteRule ^/(.*?)(/(\d+))?$ /index.php?ID=$3&url=$1&%1 [NC,L]
<VirtualHost>
Possible workarounds I see now are to make a VirtualHost for every
developer
on the site with fixed DocumentRoot and rewrite rules as they will be on
the
production site. The second option is to make additional rewrite rules
which
are not going to be applied on the production server. The third option
is my
favorite and that is to use mod_vhost_alias and mod_rewrite together.
I think mod_vhost_alias should return the proper document root. If I
turn on
the Rewrite Rules the document root for virtualHost is /var/www/html
which is
the document root set up in httpd.conf as the document root for the
default site.
If I switch of the rewrite rules I get the proper document root.
Does anybody have some idea what would be the simplest and easiest
workaround?
Any suggestions are welcome. Thanks!
Marko
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org