Question

I'm bulding a RESTful api based on Tonic. On my developer machine and our stage server we use virtual hosts.

Tonic uses a .htaccess file to translate the incomming calls to it's dispatcher.php file. This works fine on servers without VirtualHosts enabled.

However if i enable VirtualHosts i get a file not found even thought the path and name to the file is correct.

Here is the VirtualHost setup on my developer machine.

<VirtualHost *:80>
    ServerAdmin admin@xxxxxxxxxxxx
    ServerAlias *.dev.xxxxx
    VirtualDocumentRoot /home/xxxxxxxx/workspace/%1
    <Directory /home/xxxxxxxx/workspace/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

And Tonic's .htacces located in a folder called rest in the project root:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !dispatch\.php$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* dispatch.php [L,QSA]
</IfModule>

A call to http://project.dev.xxxxx/rest/ gives:

Not Found
The requested URL /home/xxxxxxxx/workspace/project/rest/dispatch.php was 
not found on this server.

Apache/2.2.22 (Ubuntu) Server at xxxxxxx Port 80
Was it helpful?

Solution

It appears as though you're misusing VirtualDocumentRoot. Try changing it to:

DocumentRoot /home/xxxxxxxx/workspace/project/rest

Also, here's a good explanation on the VirtualDynamicRoot: Dynamically configured mass virtual hosting

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top