lundi 31 octobre 2016

Rewrite http to https after set project to root directory from public directory

I have removed the public directory from laravel 5.3 and set my project to root directory. I renamed the server.php in the root directory to index.php and copied .htaccess file to the root directory as discussed in this answer This works fine. Now I tried to redirect http to https and non-www to www. Below is my .htaccess file:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On


    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    RewriteCond %{HTTPS} off
    RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ $1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]



    RewriteRule ^.*\.env$ [NC,L]
    RewriteRule ^.*\.json$ [NC,L]
    RewriteRule ^.*\.xml$ [NC,L]
    RewriteRule ^.*\.md$ [NC,L]
    RewriteRule ^.*\.js$ [NC,L]
    RewriteRule ^.*\.zip$ [NC,L]
</IfModule>

Now nothing is broken except the url. It shows as follows: http://ift.tt/2f8Pra3

Can anyone help me with this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fw0b6e
via IFTTT

Aucun commentaire:

Enregistrer un commentaire