Configuring Symfony 5 Application on Apache server

I need some help with configuring Symfony on apache2 web server.

My current project category structure is:


Inside public_html is where my Symfony application is located.

I am stuck at figuring our what I am doing wrong in my either .htaccess or /etc/apache2/sites-available/ files.

I am using symfony/apache-pack. My .htaccess files live inside /public folder as per documentation. Here it is:

DirectoryIndex index.php

<IfModule mod_negotiation.c>
    Options -MultiViews

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::$
    RewriteRule .* - [E=BASE:%1]

    RewriteCond %{HTTP:Authorization} .+
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]

    RewriteCond %{ENV:REDIRECT_STATUS} =""
    RewriteRule ^index.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ %{ENV:BASE}/index.php [L]

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 307 ^/$ /index.php/

And here is my /etc/apache2/sites-available/

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/
    <Directory /var/www/>
        AllowOverride All
        Order allow,deny
        Allow from All
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

For the moment I am still seeing folder structure.

I tried:

  1. inside .htaccess changing DirectoryIndex to /public/index.php
  2. inside .conf file changin DocumentRoot to /va/www/
  3. tried clearing cache

SO far nothings seems to help.

Would be extremely helpful for any advice.

Thank you!

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *