簡體   English   中英

使用Laravel進行子域路由

[英]Subdomain routing with Laravel

我在正確設置子域路由時遇到了一些麻煩。 我認為我在計算機上的htaccess或虛擬主機方面存在一些問題。

我的路線如下所示:

Route::group(array('domain' => 'store.munia.dk'), function()
{
    Route::get('/', array('as' => 'store', 'uses' => 'Store\PageController@getHome'));
    Route::get('faq', array('as' => 'store.faq', 'uses' => 'Store\PageController@getFaq'));
    Route::get('documentation', array('as' => 'store.documentation', 'uses' => 'Store\PageController@getDocumentation'));
}

這在本地有效,但是在我的生產機器上,只有第一條路線可用。 其他路線將獲得:

找不到:在此服務器上找不到請求的URL /文檔。

從Apache。

有誰知道這里的問題是什么? 我正在使用Laravel的默認htaccess文件,但尚未對Apache設置進行任何更改。

這是我的虛擬主機配置:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

這里缺少的是虛擬主機配置中的AllowOverride選項。 此選項指定是否將尊重.htaccess文件並應用其內容。 這應該使其運行:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    <Directory "/var/www/html">
        AllowOverride all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

您應該在apache2中啟用mod_rewrite 您可以在您的網絡服務器中輕松完成此操作

sudo a2enmod rewrite

之后,您應該重新啟動apache2

sudo service apache2 restart

那應該解決你的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM