Bonjour,
Je ne parviens pas à lire mes assets lors du déploiement de Symfony 5 sur un serveur mutuel

J’ai déploié une application Symfony 5 sur un serveur mutuel. Donc je ne dispose pas tout le contrôle sur ce serveur. Néanmoins, je peux utiliser le FTP et le SSH avec composer 1 (obsolète).

Mon problème, je parviens à accéder à tous mes url après avoir générer les .htaccess mais les images et les fichiers CSS et JavaScript ne se chargent pas. J’utilise la bibliothèque Encore pour mes assets.

Egalement pour la réécriture de mes url, j’ai installé apache-pack avec la commande composer require symfony/apache-pack sur la machine locale et j’ai transféré via FTP les deux fichiers .htaccess générés sur le serveur de l’hébergeur aux même emplacements.

Voici le .htaccess qui se trouve à la racine

Code apache : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteBase /
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ PVSPD/public/index.php [QSA,L]
</IfModule>

Et voici celui qui se trouve dans le dossier public

Code apache : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php
 
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options +FollowSymlinks
 
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
 
<IfModule mod_rewrite.c>
    RewriteEngine On
 
    # Determine the RewriteBase automatically and set it as environment variable.
    # If you are using Apache aliases to do mass virtual hosting or installed the
    # project in a subdirectory, the base path will be prepended to allow proper
    # resolution of the index.php file and to redirect to the correct URI. It will
    # work in environments without path prefix as well, providing a safe, one-size
    # fits all solution. But as you do not need it in this case, you can comment
    # the following 2 lines to eliminate the overhead.
    RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
    RewriteRule .* - [E=BASE:%1]
 
    # Sets the HTTP_AUTHORIZATION header removed by Apache
    RewriteCond %{HTTP:Authorization} .+
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
 
    # Redirect to URI without front controller to prevent duplicate content
    # (with and without `/index.php`). Only do this redirect on the initial
    # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    # endless redirect loop (request -> rewrite to front controller ->
    # redirect -> request -> ...).
    # So in case you get a "too many redirects" error or you always get redirected
    # to the start page because your Apache does not expose the REDIRECT_STATUS
    # environment variable, you have 2 choices:
    # - disable this feature by commenting the following 2 lines or
    # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    #   following RewriteCond (best solution)
    RewriteCond %{ENV:REDIRECT_STATUS} =""
    RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
 
    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    # Rewrite all other queries to the front controller.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
 
<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the start page to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 307 ^/$ /index.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

Et voici mon répertoire public

Nom : Nouvelle image (6).jpg
Affichages : 158
Taille : 4,8 Ko

Voici le fichier fichier base.html.twig

Nom : Nouvelle image (9).jpg
Affichages : 157
Taille : 138,4 Ko

Et quand j’essayé de vérifier dans l’inspecteur du navigateur, j’obtiens ceci

Nom : Nouvelle image (8).jpg
Affichages : 148
Taille : 184,2 Ko

Et pour les images dans l’inspecteur, voici l'exemple de ce que j'obtiens

Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
<img id="imag1" src="/img/imag1.jpg" alt="imag1" class="picture">

S'il vous plait, si quelqu'un à une idée sur comment résoudre ce problème, qu'il me vient en aide