Symfony 4 + Apache 2.4 + mod_rewrite not working

荒凉一梦 提交于 2019-12-06 05:00:33

This is possibly caused due to a bug in Apache for versions prior to Apache 2.4.18.

There was an Apache bug with FallbackResource when being called on the home page causing Apache to hang.

The Apache bug details can be found here: https://bz.apache.org/bugzilla/show_bug.cgi?id=58292

I've added a PR to update the Symfony docs

Ok, finally I got:

It was a misconfiguration here:

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        # RewriteCond %{REQUEST_FILENAME} !-f
        # RewriteRule ^(.*)$ index.php [QSA,L]
        FallbackResource "index.php"
    </IfModule>

I was following what is said here: https://httpd.apache.org/docs/2.4/rewrite/remapping.html

But then I tried to do without this FallbackResource, back to what Symfony documentation gave me, with this:

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php [QSA,L]
    #       FallbackResource "index.php"
    </IfModule>

Now it's working.

Thank you all

If you use Linux:

$ [sudo] a2enmod rewrite

If you are using apache 2.4, have mod_rewrite already enabled, and getting something like the below in your virtualhost error log file:

[Thu Apr 05 15:08:55.619587 2018] [authz_core:error] [pid 2382] [client 10.0.1.1:51436] AH01630: client denied by server configuration: /vagrant/public/

Then update your virtual host and replace:

Order Allow,Deny

Allow from All

with

Require all granted

Also be sure to update /var/www/project/public/bundles to your actual directory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!