You are not logged in.
Hi,
I have an apache webserver on my machine, anch I am trying to set up multiple webroots with VirtualDocumentRoot.
From my httpd.conf:
<VirtualHost *:80>
ServerName webserver
ServerAlias *.webserver
UseCanonicalName Off
VirtualDocumentRoot /home/stefano/webroot_aliases/%1
Options -Indexes FollowSymLinks
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3
<Directory /home/stefano/webroot_aliases/>
Order allow,deny
Allow from all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/home/stefano/webroot_aliases/(.*)$ index.php?url=$1 [QSA,L]
</Directory>
</VirtualHost>
So, I have a set of symlinks on /home/stefano/webroot_aliases which point to several webroot directories.
If I request e.g. http://liv.webserver , I get the homepage on /home/stefano/webroot_aliases/liv/index.php.
All style sheet, js, images, and what else is attached to the html is fetched correctly.
But, if I look for http://liv.webserver/news/16 , I get an "Object not found" error.
I have this on my rewrite log:
192.168.1.50 - - [18/Oct/2010:15:15:42 --0500] [liv.webserver/sid#7bcdb0][rid#a3a820/initial] (3) [perdir /home/stefano/webroot_aliases/] add path info postfix: /home/stefano/webroot_aliases/liv/news -> /home/stefano/webroot_aliases/liv/news/16
192.168.1.50 - - [18/Oct/2010:15:15:42 --0500] [liv.webserver/sid#7bcdb0][rid#a3a820/initial] (3) [perdir /home/stefano/webroot_aliases/] strip per-dir prefix: /home/stefano/webroot_aliases/liv/news/16 -> liv/news/16
192.168.1.50 - - [18/Oct/2010:15:15:42 --0500] [liv.webserver/sid#7bcdb0][rid#a3a820/initial] (3) [perdir /home/stefano/webroot_aliases/] applying pattern '^/home/stefano/webroot_aliases/(.*)$' to uri 'liv/news/16'
192.168.1.50 - - [18/Oct/2010:15:15:42 --0500] [liv.webserver/sid#7bcdb0][rid#a3a820/initial] (1) [perdir /home/stefano/webroot_aliases/] pass through /home/stefano/webroot_aliases/liv/news
So it looks like apache is redirecting, but it's not parsing the php file.
Apache error log reports this:
[Mon Oct 18 15:28:25 2010] [error] [client 192.168.1.50] File does not exist: /home/stefano/webroot_aliases/liv/news, referer: http://liv.webserver/
What I am doing wrong?
Thanks
gm
Offline
Did you manage to solve the issue? 'cause I have a similar one.
I'm coming a bit late, but I think that putting a slash in front of your index.php in the rewrite rule should help.
Anyway, my problem, as I said, is similar: I've got a bunch of virtual hosts that I use only for development purposes. They used to work with a file for each virtual host, each containing a <VirtualHost> block. Since they started to grow in number, I thought a VirtualDocumentRoot approach would be much more appropriate, so I setup my httpd-vhosts.conf like this:
UseCanonicalName Off
VirtualDocumentRoot /srv/http/vhosts/%1/htdocs
<VirtualHost 127.0.0.1:80>
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog "/var/log/httpd/virtual.access.log" vcommon
ErrorLog "/var/log/httpd/virtual.error.log"
<Directory /srv/http/vhosts/%1/htdocs/>
DirectoryIndex index.htm index.html index.php
Options Indexes FollowSymLinks MultiViews +Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I kept it very simple and it works until it comes to mod_rewrite-ing addresses.
I use Drupal and the "RewriteBase /" line is uncommented, as the Drupal's .htaccess itself suggests, but every time I issue an http://myvhost/example-request I get 404 errors. This is an excerpt of the log:
myvhost 127.0.0.1 - - [07/Nov/2011:13:36:11 +0100] "GET /example-request HTTP/1.1" 404 1193
I guess I'm doing something wrong in the apache config file, but I can't figure it out.
Any hint?
Thanks
Linux Registered User #362737
Offline