Home Symfony 4 + Apache 2.4 + mod_rewrite not working
Reply: 0

Symfony 4 + Apache 2.4 + mod_rewrite not working

user2406
1#
user2406 Published in April 20, 2018, 6:04 pm

What am I doing wrong?

This is my config on /etc/apache2/sites-enabled/hello-world.conf

<VirtualHost *:80>
    ServerName hello-world
    DocumentRoot "/home/carlos/dev/github/hello-world/public"

<Directory "/home/carlos/dev/github/hello-world/public">
    AllowOverride None
    Order Allow,Deny
    Allow from All

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

# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
#     Options FollowSymlinks
# </Directory>

# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/project/public/bundles>
    <IfModule mod_rewrite.c>
        RewriteEngine Off
    </IfModule>
</Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

When I try to access http://hello-world/index.php/lucky/number all goes right.

But with http://hello-world/lucky/number I get a 404 Not Found.

The 404 error was due I had configure two VirtualHosts. One in /etc/apache2/sites-enabled/000-default.conf and other in /etc/apache2/sites-enabled/hello-world.conf. I removed that in 000-default.conf, and now I'm receiving a "500 Internal Server Error". I change this lines:

<Directory "/home/carlos/dev/github/hello-world/public"> 
# AllowOverride None 
# Order Allow,Deny 
Require all granted 
# Allow from All – 

...but still I'm getting the 500.

On /var/log/apache2/project_error.log there's this message:

[Thu Apr 05 19:56:25.819680 2018] [core:error] [pid 4277] [client 127.0.0.1:38800] AH00125: Request exceeded the limit of 10 subrequest nesting levels due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306379 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO