-
Laravel HTTPS
Buongiorno, ho già cercato online e sono riuscito a configurare laravel sul mio progetto altervista tramite i seguenti htaccess
File .htaccess in /
Codice HTML:
# av:php5-engine
AddHandler av-php82 .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}/public%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^.*$ https://%{HTTP_HOST}/public%{REQUEST_URI} [L,R=301]
</IfModule>
File .htaccess in /public
Codice HTML:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Nell'AppServiceProvider ho inserito:
Codice HTML:
if ($this->app->environment('production')) {
URL::forceScheme('https');
}
funziona tutto se non fosse che le pagine /public sono raggiungibili sia in http che https e vorrei disabilitare l'http.
navigando dalla pagina i redirect sono correttamente in https ma se modifico l'url a mano l'http è valido e non riesco ad uscirne.
ho provato anche a modificare il file htaccess in /public aggiungendo il redirect in https ma mi risponde TOO MANY REDIRECT :???:
-
Dalla root che forza in https per il domino di terzo livello di altervista "fralaratest" , se necessario forza la visibilità di Authorization in php
Codice:
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule .* https://fralaratest.altervista.org%{REQUEST_URI} [L,R=301]
La riscrittura mod_rewrite ".htaccess" viene ereditata dalla cartella padre a meno che la directory corrente non usi la riscrittura che sovrascrivere la direttiva già presente nella root
Se devo creare un file .htaccess dentro la cartella public necessito (specialmente su altervista) del RewriteBase /public/ dopo aver accesso il motore "mod_rewrite" RewriteEngine On