Support the ongoing development of Laravel.io →
Configuration Requests Installation

Hi, 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. 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:

https://www.mywebsite.com/index.php/my_parameters

Can anyone help me with this?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

janakad janakad Joined 21 Sep 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.