0

summary:

  1. my-host-here.com/app_dev.php/main = works

  2. my-host-here.com/main = 404 error

  3. my-host-here.com/app.php/main = also gets a 404 error

I've looked at various links (symfony.com and discussions here in SO) and tried their suggestions/answers but no luck here.

Any ideas on how to fix it? Thanks a lot!

I'm using Apache 2.4.x/PHP 5.4.x which were installed using the yum repository on RHEL7.

snippet of httpd.conf

Include conf.modules.d/*.conf

snippet of 00-base.conf which resides inside conf.modules.d

LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule slotmem_plain_module modules/mod_slotmem_plain.so

snippet of 10-php.conf which resides inside conf.modules.d

LoadModule php5_module modules/libphp5.so

snippet of my virtualhost config file

<VirtualHost *:80>
ServerName my-host-here.com
DocumentRoot /opt/www/my-host-here/web

<Directory /opt/www/my-host-here/web/>
  DirectoryIndex app.php
  AllowOverride All   
  Require all granted

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

The contents of the .htaccess inside /opt/www/my-host-here/web is whatever Symfony came with. I never changed it. Symfony project was created using the command:

symfony new my_project_name lts
4
  • github.com/symfony/symfony-standard/blob/master/web/.htaccess Commented Aug 1, 2016 at 4:15
  • @zerkms I looked at approot/web/ and it seems I have that exact same file already. Commented Aug 1, 2016 at 4:25
  • is mod_rewrite enabled in apache2? symfony contains the correct .htaccess file by default, so you shouldn't do anything for this. see stackoverflow.com/questions/9021425/… Commented Aug 1, 2016 at 9:52
  • @NDM yes. mod_rewrite is enabled. I'll edit the original post. Commented Aug 1, 2016 at 10:23

1 Answer 1

1

Here is my settings:

/etc/apache2/sites-available/project.conf

  <VirtualHost *:80>
    ServerName project       
    DocumentRoot /path/to/project/web 

    <Directory /path/to/project/web >
        Options Indexes FollowSymlinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /path/to/project/error.log
    CustomLog /path/to/project/access.log combined
  </VirtualHost>

web/.htaccess

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Explicitly disable rewriting for front controllers
    # RewriteRule ^app.php - [L]
    RewriteRule ^app_dev.php - [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    # Change below before deploying to production
    # RewriteRule ^(.*)$ app.php [QSA,L]
    RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.