laravel - 如果 url 中没有 index.php,Laravel 7.10 新安装不起作用
问题描述
我已经安装了全新的 laravel 安装,一切正常,除了如果我在最后没有输入 index.php 的情况下转到 url,那么它就不起作用。
我在用:
http://localhost/index.php
在这种情况下,页面显示正确,但如果我只输入:
http://localhost/
然后它没有按预期工作。
如何查看它是否有效,我已经安装了调试栏,在第一种情况下它显示但在第二种情况下它不是。
我已经更新了 apache2 配置,以便它在公共目录中启动,并且我确保它接受 000-default.conf 中带有 DirectoryIndex index.php 的 php。
我是否应该设置一些东西,以便在浏览器中点击目录时强制重定向到 index.php?
这是我从 phpinfo 中获得的 apache2 处理程序中已加载模块的信息,我可以看到 mod_rewrite
Loaded Modules
core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_deflate mod_dir mod_env mod_filter mod_mime prefork mod_negotiation mod_php7 mod_reqtimeout mod_rewrite mod_setenvif mod_status
解决方案
请更改 httpd.conf 文件的内容,如下所示。
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
...
Listen 8094
<VirtualHost *:8094>
DocumentRoot "D:\yoursouce\public"
<Directory "D:\yoursouce\public">
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
...
然后尝试
http://localhost:8094/
此致
推荐阅读
- hp-uft - UFT 在 IE 中找不到对象
- c++ - g++ 和 clang++ 通过引用捕获 `std::integral_constant` 的不同行为
- python - 输出与预期不同
- c# - GenericArguments[0], 'EntityGenericBase`1[TModel]' 违反了类型参数 'TModel' 的约束
- powershell - 命令 'bison name.y' 不起作用,但不会给出任何错误。系统路径正确设置
- java - 在 Kotlin/Java 变量名中使用特殊字符“$”
- c# - 字符串数组中的引用是否必须是连续的?
- css - 如何在不占用下方空间的情况下创建可悬停的下拉菜单?
- angular - Angular RouteResolver 只能无延迟地工作,存在可观察的问题
- windows - windows mobile上的css下拉菜单非常慢