We are running on shared hosting and running laravel on main domain that is example.com
, everything is working perfectly fine.
We have crated a sudbomain test.example.com
by vising Subdomains manager in cPanel and pointed it's document root to /public_html/test
As soon as we visit test.example.com
we get 500 Internal Server Error
Initial laravel's .htaccess is
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
We have changed.
RewriteRule ^ index.php [L]
to
RewriteRule ^ /index.php [L]
Now if we visit test.example.com
it redirect to tests.example.com/test
and everything works normally.
But we not sure why it is redirecting browser to tests.example.com/test
?
Updated
After further research we found that.
If we remove this line.
RewriteRule ^(.*)/$ /$1 [L,R=301]
Then both maindomain and subdomain working perfectly fine. But is it OK to remove this line.
In short we want to run laravel on main domain and something else on subdomain.
You can add a restriction on
test
subdomain.Also, you have to avoid removing trailing slash for folders (otherwise: loop -> 500 error).
Your htaccess would then become