I moved my Laravel application from the development localhost to an internet production subdomain.
On localhost everything works. But when I move app to subdomain it seems .htaccess can not handle redirects correctly.
When i type to browser sub.mydomain.com
it redirect to sub.mydomain.com/public
. Main webpage renders. But when i go to login page it returns 500 error. route is now sub.mydomain.com/public/login
It works only when i manualy type sub.mydomain.com/public/index.php/login
I do not know why is this happens, but on localhost it works fine.
My root .htaccess:
RewriteEngine on
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
And my /public .htaccess
<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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Can you advise me how to properly configure htaccess to make it work properly?