Virtual host with rewrite does not execute .htaccess file. Used to work on Centos with Apache 2.2.

  • Posted on December 18, 2014
  • DuGiAsked by DuGi


So I’ve just switch from another VPS provider to Digital Ocean and I’m loving it so far. Also with the switch I chose to switch from Centos 6 to Ubuntu 14. Very nice so far :)

But now I’ve run into a bit of a problem. The VPS is used as a development environment for multiple web developers.

Each developer has their own user and home directory:



But they are all hosted on the same domain. So i.e. a path to one of their projects could look like this:


This way each developer can have their own version of the same project hosted on the same domain :)

ANYWAY, here’s my problem.

On our previous VPS I used the following vhost file:

<VirtualHost *:80>
        ServerAlias *

        # Set development environemnt variable
        SetEnv DEVELOPMENT true

        # Enable rewrite for dynamic developer environments
        RewriteEngine On

        # Dynamic developer environment
        RewriteCond %{HTTP_HOST} ^(.+)\.(.+)\$
        RewriteRule ^/(.*)$  /home/%1/sites/%2/$1  [L]

        # Enable .htaccess files
        <Directory />
                AllowOverride All

        # PHP Settings
        php_value error_reporting 30719
        php_value display_errors On
        php_value display_startup_errors On
        php_value post_max_size 100M
        php_value upload_max_filesize 100M

But now each developer gets a 403 forbidden file. The error.log shows the following message:

[Thu Dec 18 10:41:45.981506 2014] [autoindex:error] [pid 5527] [client] AH01276: Cannot serve directory /home/developer1/sites/projectname/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive

Also might be worth mentioning that our projects we develop are made with the Laravel framework. So each project lands on the root of the project. And in that root here’s a .htaccess file that redirects each request to the /public/ folder. This is to avoid having /public/ appended to all the URL’s in the project.

And it is THAT .htaccess file that doesn’t get executed. We’re never hitting the content of the /public/ folder.

I hope my question make sense and that some of you out there can help a brother out! :)

Merry Christmas and everything from Morten / DuGi

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


I had a similar problem, to fix that I had to update my AllowOverride rule to:

        <Directory /var/www/project/public>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted

Then I ran a config test:

apachectl -t

I made sure that I got Syntax OK and then restarted Apache:

systemctl restart apache2

Regards, Bobby

This comment has been deleted