Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

[Solved] Apache Installation Notes - mod_rewrite, Virtual Hosts

Hello,

my question is about this sentence from Apache installation notes "And this second configuration allows you to install a Phalcon application in a virtual host:"

http://docs.phalconphp.com/en/latest/reference/apache.html

That implies that one cannot use virtual hosts if rewrite rules are placed in .htaccess files. I don't think this is true, but I could be wrong, since I am not an expert in apache configuration. What I know is that I have used, and I am actually using similar configuration (mod rewirte rules in .htaccess file.) with Zend framework, and Virtual Hosts work fine, as far as I can see...

Could anyone explain this a bit, and/or point me in right direction. Have I overlooked something here, what?



1.5k
edited Jun '14

The latest section isn't meant as a copy-paste. It shows a simple virtual host without the rewrite rules.

The rewrite rules could just as well be placed in the virtuals hosts as you mentioned.

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/var/vhosts/test/public"
    DirectoryIndex index.php
    ServerName example.host
    ServerAlias www.example.host

    <Directory "/var/vhosts/test/public">
        Options All
        AllowOverride All
        Allow from all
    </Directory>

    <IfModule mod_rewrite.c>
        <Directory "/var/www/test/public">
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
        </Directory>
    </IfModule>
</VirtualHost>


3.6k

I haven't said it is meant as a copy paste.

I didn't include rewrite rules in virtual hosts file, but in in .htaccess.

The documentations implies, if I understand it correctly, that we cannot have rules in htaccess file if want to use virtual hosts...



1.5k
Accepted
answer

Imho it doesn't imply that it can't be done. And the fact is that it actually can be done. It doesn't explicilty say it can be done, they are snippets meant to show the possibities, not all the different setups possible.

However, if you think the wording could be better and maybe show more examples than you could open a issue for the docs and someone might fix it.

The docs aren't as clear then, but it can be done just like you've done with Zend framework and I've shown in the previous comment.



3.6k

Well, the docu mentiones two possibilities, and than says the second one allows using of virtual hosts. To me this looks like implying that virtual hosts won't work with the first configuration option. But never mind.

It is probably a mistake, on my side, in understanding, or whatever. The main thing is that virual hosts can be used with different ways of mod rewrite configurations.

Thanks for your answers!