Configuring Symfony 5 Application on Apache server

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

My current project category structure is:

var/www/domain.com/public_html

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/domain.com.conf 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>

<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>

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

And here is my /etc/apache2/sites-available/domain.com.conf

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

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/domain.com/public_html/public
  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 *