gpt4 book ai didi

php - 如果不在 url 上添加 index.php,laravel 5.2 项目将无法运行

转载 作者:可可西里 更新时间:2023-11-01 00:56:37 26 4
gpt4 key购买 nike

大家好,我正在 Laravel 5.2 上开发我的项目。我已经在我的本地机器上设置了我的项目,但它现在可以在不在 url 中添加 index.php 的情况下工作。

我请求 url :-

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>

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

最佳答案

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

<?php
phpinfo();
?>

在终端运行命令:

$ sudo a2enmod rewrite

关于php - 如果不在 url 上添加 index.php,laravel 5.2 项目将无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40722058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com