Search code examples
symfonysymfony4

Symfony4 project deployment


I'm working on my first symfony 4 project and i would like to upload it on my online server. My goal is to have it online on my domain to test it before a preview with my client.

I tried to put my files on the www folder (by ftp) and add a .htaccess in the main repository with :

<IfModule mod_rewrite.c>RewriteEngine On

# remove "www" from URI
RewriteCond %{HTTP_HOST} ^devfuzz\.(.+) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

# force HTTPS
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# use public as starting point
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]</IfModule>

And i added a .htaccess in public with :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

I tried so many thing found on many forum but i have always the same with when i try to go on my website :

website view

How can i change this view to have a normal navigation like i had with : php bin/console server:run in local


Solution

  • Try to change your code with this one :

      # remove "www" from URI
      RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
      RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
    

    You don't need to remove the www in this part of code, this code will do it for you so do NOT change it :)