user2206893
user2206893

Reputation: 21

Always getting 404 error with Symfony

I am a beginner into Symfony, and I'm having troubles to made it works. I'm running apache 2 on my machine (ubuntu). It seems that I can reach the configuration by the url: localhost/Symfony/web/config.php

Also, I can reach the main page by this url: localhost/Symfony/web/app_dev.php (the first I see is a message telling: An error occurred while loading the web debug toolbar (404: Not Found). Do you want to open the profiler?). The only thing I can is to respond is cancel (If y try accept, I get a 404 not found).

After that, nothing works. Even the . Always 404 not found.

As I can found, it can be a problem with the cache or maybe with apache config. But whatever I try it doesn't solve the issue (other people ask similar here in stackoverflow, but nothing fix for me).

Anybody knows? Thanks in advance.

Upvotes: 2

Views: 7963

Answers (2)

Frederick G. Sandalo
Frederick G. Sandalo

Reputation: 929

I used to have this problem too, please take a look at my configurations and try them out

inside my .htaccess:

Hi all, I have been having this problem too. And it seems that the "stock" .htaccess is the problem. I have solved this in my environment and here is my .htaccess with notes:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess point the request to app_dev.php, since the routing.yml is empty initially
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the startpage to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>

inside my "symfony" entry in /etc/apache2/sites-available:

<VirtualHost 127.0.1.15>
    ServerAdmin webmaster@localhost
    ServerName symfony
    DocumentRoot /var/www/Symfony/web
DirectoryIndex app.php
    <Directory /var/www/Symfony/web>
        Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Upvotes: 4

Eernie
Eernie

Reputation: 469

Maby take a look at your .htaccess or your appache setting (mod_rewrite)

Look at : Symfony 404 errors

Upvotes: 0

Related Questions