Php Laravel子域500错误
我们在共享主机上运行,在主域上运行laravel,即Php Laravel子域500错误,php,apache,.htaccess,laravel-4,Php,Apache,.htaccess,Laravel 4,我们在共享主机上运行,在主域上运行laravel,即example.com,一切正常 通过访问cPanel中的Subdomains manager,我们创建了一个sudbomaintest.example.com,并将其文档根指向/public\u html/test 我们一访问test.example.com就会得到500个内部服务器错误 初始laravel's.htaccess是 <IfModule mod_rewrite.c> <IfModule mod_nego
example.com
,一切正常
通过访问cPanel中的Subdomains manager,我们创建了一个sudbomaintest.example.com
,并将其文档根指向/public\u html/test
我们一访问test.example.com
就会得到500个内部服务器错误
初始laravel's.htaccess是
<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>
到
现在,如果我们访问test.example.com
它会重定向到tests.example.com/test
,一切正常
但我们不知道为什么它会将浏览器重定向到tests.example.com/test
已更新
经过进一步研究,我们发现
如果我们去掉这条线
RewriteRule ^(.*)/$ /$1 [L,R=301]
然后,主域和子域都可以很好地工作。但是可以把这条线去掉吗
RewriteRule ^(.*)/$ /$1 [L,R=301]
简而言之,我们希望在主域上运行laravel,在子域上运行其他内容。您可以在
测试
子域上添加限制。此外,您必须避免删除文件夹的尾部斜杠(否则:循环->500错误) 然后,您的htaccess将成为
<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>
选项-多视图
重新启动发动机
#当来自测试子域时,不要触摸任何东西
重写cond%{HTTP_HOST}^test\。[北卡罗来纳州]
重写规则^-[L]
#重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写规则^(+)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^/index.php[L]
tests.example.com/public怎么办?test.example.com
中没有任何内容,只有带有phpinfo()的文件index.php
代码>在里面。你是说/public\u html/test里面没有laravel?只是index.php?@EimantasGabrielius如果我们删除,RewriteRule^(.*)/$/$1[L,R=301]
,那么子域和主域都无法正常工作。但不确定是否可以远程此。是的/public\u html/test
文件夹不包含laravel,它只包含index.php
文件。Laravel安装在/public\u html
(主域)中
<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>