laravel 5.2项目没有运行而没有在url上添加index.php

时间:2016-11-21 14:04:10

标签: php laravel

Hello Everyone我正在处理Laravel 5.2上的项目。我已经在我的本地机器上设置了我的项目,但它现在正在工作而不在url中添加index.php。

我要求提供网址: -

http://localhost/project_folder/admin

虽然我试图在没有index.php的情况下运行并运行我的url但它会给我以下错误。

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 webmaster@localhost
    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>

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

1 个答案:

答案 0 :(得分:4)

请启用模式重写。 请确保您的系统上有mod重写启用。(在有代码的info.php中搜索mod_rewrite)

<?php
phpinfo();
?>
终端运行命令中的

$ sudo a2enmod rewrite