2016-11-21 101 views
3

大家好,我正在为Laravel 5.2中的项目工作。我已经在我的本地机器上设置了我的项目,但它现在工作时没有在url中添加index.php。laravel 5.2项目没有在url上添加index.php没有运行

我随URL请求: -

http://localhost/project_folder/admin 

虽然我想没有的index.php就跑我的网址它给了我下面的错误。

Not Found 

The requested URL /project_folder/admin was not found on this server. 

为此,我做了以下步骤:1 )提供许可(777)存储和缓存文件夹。 2)我去路径/etc/apache2/sites-available/000-default.conf并编辑它,现在它看起来像这样。

<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 [email protected] 
    DocumentRoot /var/www/html 

    # 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 

<Directory /var/www/html> 
    Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 
     allow from all 
</Directory> 
</VirtualHost> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

在我的.htaccess文件中有以下代码。

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    #RewriteRule ^(.*)/$ /$1 [L,R=301] 
    RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 

    # Handle Authorization Header 
    RewriteCond %{HTTP:Authorization} . 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
</IfModule> 

如果我忘记了任何需求或其他事情,请给我建议。

+0

没有'的DirectoryIndex index.php文件'在你的apache配置中。 Apache不知道当没有URL提供的文件时它应该打开的默认文件是什么 –

+0

[如何为Apache 2.2启用mod \ _rewrite]可能的重复(http://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2) – Matheno

+0

你是否开始Apache服务。 –

回答

4

请启用模式重写。 请确保您有您的系统上国防部重写启用终端运行命令(搜索mod_rewrite的在其代码为info.php)

<?php 
phpinfo(); 
?> 

$ sudo a2enmod rewrite