Laravel子域500错误 [英] Laravel subdomain 500 error
问题描述
我们正在运行在共享主机和运行laravel上的 example.com
,一切工作完全正常的主域名。
We are running on shared hosting and running laravel on main domain that is example.com
, everything is working perfectly fine.
我们已经在的cPanel 的装箱一sudbomain test.example.com
通过vising的子站点管理器的,并指出它的文档根 /的public_html /测试
We have crated a sudbomain test.example.com
by vising Subdomains manager in cPanel and pointed it's document root to /public_html/test
当我们访问 test.example.com
我们得到的 500内部服务器错误
As soon as we visit test.example.com
we get 500 Internal Server Error
初始laravel的htaccess的是
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>
我们已经改变了。
RewriteRule ^ index.php [L]
到
RewriteRule ^ /index.php [L]
现在,如果我们访问 test.example.com
重定向到 tests.example.com/test
和一切正常工作。
Now if we visit test.example.com
it redirect to tests.example.com/test
and everything works normally.
但是,我们不知道为什么它被重定向浏览器 tests.example.com/test
?
But we not sure why it is redirecting browser to tests.example.com/test
?
更新
在进一步研究后,我们发现这一点。
After further research we found that.
如果我们删除此行。
RewriteRule ^(.*)/$ /$1 [L,R=301]
然后两个maindomain和子工作完美的罚款。但它是确定删除此行。
Then both maindomain and subdomain working perfectly fine. But is it OK to remove this line.
总之,我们要在主域和其他东西的子站点运行laravel。
In short we want to run laravel on main domain and something else on subdomain.
推荐答案
您可以在测试
添加子域名的限制。
此外,你必须避免去除尾随斜杠的文件夹。(否则:循环 - > 500错误)
You can add a restriction on test
subdomain.
Also, you have to avoid removing trailing slash for folders (otherwise: loop -> 500 error).
那么你的htaccess将成为
Your htaccess would then become
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Don't touch anything when coming from test subdomain
RewriteCond %{HTTP_HOST} ^test\. [NC]
RewriteRule ^ - [L]
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
</IfModule>
这篇关于Laravel子域500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!