Laravel 5.1路线问题

时间:2015-12-09 07:55:18

标签: laravel-5.1 laravel-routing

我已经安装了laravel框架(最新版本5.1),安装成功后,我在访问欢迎刀片页面时在localhost上遇到了路径问题。通常可以通过localhost/laravel/public来访问它,但是当我写这个网址时,它会重定向到localhost/public,而404找不到页面会打开。当我在localhost/laravel/public/index.php访问欢迎页面时,会显示欢迎页面。通常路径为localhost/laravel/public,但在我的情况下为localhost/laravel/public/index.php。如何通过localhost/laravel/public访问欢迎页面?

1 个答案:

答案 0 :(得分:0)

这基本上是Apache配置,请确保具有以下内容:

  1. 您的文档路由是公共目录。因此http://localhost可以直接回复欢迎页面。
  2. 确保.htaccess目录中有/laravel/public个文件。
  3. 确保已启用mod-rewrite
  4. 以下示例Apache配置:

    <VirtualHost *:80>                                                                                                                                                        
            # The ServerName directive sets the request scheme, hostname and port that                                                                                        
            # the server uses to identify itself. This is used when creating                                                                                                  
            # redirection URLs. In the context of virtual hosts, the ServerName                                                                                               
            # specifies what hostname must appear in the request's Host: header to                                                                                            
            # match this virtual host. For the default virtual host (this file) this                                                                                          
            # value is not decisive as it is used as a last resort host regardless.                                                                                           
            # However, you must set it for any further virtual host explicitly.                                                                                               
            #ServerName www.example.com                                                                                                                                       
    
            ServerAdmin webmaster@localhost                                                                                                                                   
            DocumentRoot /var/www/laravel/public                                                                                                                 
    
            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,                                                                                            
            # error, crit, alert, emerg.                                                                                                                                      
            # It is also possible to configure the loglevel for particular                                                                                                    
            # modules, e.g.                                                                                                                                                   
            #LogLevel info ssl:warn                                                                                                                                           
    
            ErrorLog ${APACHE_LOG_DIR}/error.log                                                                                                                              
            CustomLog ${APACHE_LOG_DIR}/access.log combined                                                                                                                   
    
            # For most configuration files from conf-available/, which are                                                                                                    
            # enabled or disabled at a global level, it is possible to                                                                                                        
            # include a line for only one particular virtual host. For example the                                                                                            
            # following line enables the CGI configuration for this host only                                                                                                 
            # after it has been globally disabled with "a2disconf".                                                                                                           
            #Include conf-available/serve-cgi-bin.conf                                                                                                                        
    </VirtualHost>