Quantcast
Channel: Grafikart | Derniers Sujets du forum
Viewing all articles
Browse latest Browse all 1542

[Symfony 4.4] Comment faire une redirection sans le .htacces

$
0
0

Bonjour les amis, voilà j'arrive enfin au bout de mon autoformation sur Symfony

J'ai pris un serveur VPS et installé mon projet Symfony dessus et il fonctionne très bien.

J'ai aussi installé le ssl et il fonctionne aussi.

Quand je tape https dans le navigateur ça fonctionne aussi.

Le problème que je rencontre c'est que quand je tape seulement "monsite.com" sans le https, je tombe sur la version en http et pas sur le https.

Donc il faut que je fasse une réécriture d'url.

Le soucis c'est que je n'arrive pas à faire ça sans le fichier .htaccess.

J'ai configuré le Vhost mais ça fonctionne pas.

Quelqu'un peut jeter un petit coup d'oeuil et me dire s'il comprend pourquoi ça ne fonctionne pas

voici mon Vhost

PS : Mon serveeur tourne sous Debian 10

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com


        ServerName dev.monsite.com
        ServerAlias www.dev.monsite.com
        ServerAdmin webmaster@monsite.com
        DocumentRoot /var/www/monsite.com/dev/public

        <Directory /var/www/monsite.com/dev/public >

          #Require all granted
          #AllowOverride All
          #Options Indexes

          RewriteEngine on
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          allow from all
          #RewriteRule ^(.*) /public/$1 [L]
          #RewriteCond %{HTTP_HOST} ^monsite.com
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

         RewriteCond %{SERVER_NAME} =www.monsite.com [OR]
         RewriteCond %{SERVER_NAME} =monsite.com
         RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]



Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/dev.monsite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.monsite.com/privkey.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com


        ServerName dev.monsite.com
        ServerAlias www.dev.monsite.com
        ServerAdmin webmaster@monsite.com
        DocumentRoot /var/www/monsite.com/dev/public

        <Directory /var/www/monsite.com/dev/public >

          #Require all granted
          #AllowOverride All
          #Options Indexes

          RewriteEngine on
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          allow from all

          FallbackResource /index.php
          #RewriteRule ^(.*) /public/$1 [L]
          #RewriteCond %{HTTP_HOST} ^monsite.com
        </Directory>


        <Directory /var/www/monsite.com/dev/public/bundles>

           FallbackResource disabled

        </Directory>



        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

# Some rewrite rules in this file were disabled on your HTTPS site,

# because they have the potential to create redirection loops.

         RewriteCond %{SERVER_NAME} =www.dev.monsite.com [OR]
         RewriteCond %{SERVER_NAME} =dev.monsite.com
         RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
</IfModule>


Viewing all articles
Browse latest Browse all 1542

Trending Articles