Laravel在子域中,如何设置htaccess


laravel in subdomain, how to set up htaccess

我想在主机上设置拉拉维尔。

我的主机具有以下结构:

   /
   |- domain.net
   |- domain.com
         |- web
         |- sub
             |- supersite
             |- calendar
                  |- vendor
                  |- bootstrap
                  |- app
                     ... (all laravel files)

我的主机上的主站点domain.com位于文件夹 web 中。所有子域都在文件夹 sub 中。例如,我的 laravel网站calendar可以通过calendar.domain.com访问

我在网上找到了这个.htaccess。

DirectorySlash On
Options +FollowSymlinks -Indexes -MultiViews
AddDefaultCharset utf-8
DirectoryIndex /public/index.php
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>

app/routes.php这段代码添加到文件中

Route::get('users', function()
{
    return 'Users!';
});

我把.htaccess放到文件夹calendar.站点calendar.domain.com工作正常,但站点calendar.domain.com/users返回服务器错误 500。

你知道问题出在哪里吗?谢谢。

如果您的 DocumentRoot calender并且您无法将其更改为 calender/public则可以在日历文件夹中的 .htaccess 中使用它:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]