Php 基于Laravel的子域路由
我无法正确设置子域路由。我想我的机器上有一些关于htaccess或虚拟主机的问题 我的路线是这样的:Php 基于Laravel的子域路由,php,apache,.htaccess,laravel,routing,Php,Apache,.htaccess,Laravel,Routing,我无法正确设置子域路由。我想我的机器上有一些关于htaccess或虚拟主机的问题 我的路线是这样的: Route::group(array('domain' => 'store.munia.dk'), function() { Route::get('/', array('as' => 'store', 'uses' => 'Store\PageController@getHome')); Route::get('faq', array('as' => '
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>
服务器管理员webmaster@localhost
DocumentRoot/var/www/html
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
您应该在apache2中启用mod_rewrite。您可以在Web服务器中简单地执行此操作
sudo a2enmod rewrite
之后,您应该重新启动apache2
sudo service apache2 restart
这应该可以解决您的问题这里缺少的是虚拟主机配置中的
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>
服务器管理员webmaster@localhost
DocumentRoot/var/www/html
允许超越所有
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
Trystore.munia.dk/index.php/faq
。那么我如何处理子域的这个问题呢?删除index.php。没有子域就不需要它。我觉得子域好像没有启用.htaccess
(AllowOverride All
)您可以更改vhost配置吗?我可以。虽然我可能需要一些指导。你能编辑你的问题并添加属于子域的虚拟主机吗?@Stromgren如果应用程序的其余部分正常工作,这是如何解决你的问题的?只是好奇……我在配置本地服务器时遇到了同样的问题,对我来说,允许mod_rewrite有助于确保,但是如果OP已经运行了应用程序(在主域下),那么mod_rewrite应该已经启用,否则什么都不会起作用。这就是为什么我有点困惑。。。