【问题标题】:Why Apache(centos 7) can't see route that I made?为什么 Apache(centos 7) 看不到我创建的路由?
【发布时间】:2019-02-27 15:32:18
【问题描述】:

我做了路由,但是 apache 服务器看不到那个路由。 Laravel 欢迎页面没有问题,但是当我尝试在视图中创建另一个文件夹时。 Apache 看不到该页面。 404 未找到弹出。

这是路由和控制器代码

Route::get('/pages', 'Pages@index');

和控制器

    function index(){
    return "test";

还有我的 httpd 我的文档根目录:/var/www/html/laravel/public

模块目录: DirectoryIndex index.html index.php

我还需要更改其他内容吗?使这条路线可访问?

【问题讨论】:

  • 检查 mod 重写,apache 主机配置 - allowoverride ...
  • 试试example.com/index.php/pages如果它有效那么你必须启用apache mod rewrite
  • 实际上我正在尝试在 /etc/httpd/conf/httpd.conf 中的 mod rewite 中找到但没有。我需要自己写吗?如果是那怎么办?
  • 现在只需检查主机配置中的AllowOverride 并将其设置为All .. 您需要允许.htaccess 文件基本上使用mod_rewrite ...然后重新启动
  • 如果您获得的是 Apache 404 页面,而不是 Laravel 404,则意味着 mod_rewrite 无法正常工作......如果您搜索,您可以找到 100 多个答案来帮助您解决此问题

标签: laravel apache routes centos


【解决方案1】:

在 centos 7 中,None --to-> All 可以做到。

<Directory /var/www/html>
. . .
 # 
 # AllowOverride controls what directives may be placed in .htaccess files.
 # It can be "All", "None", or any combination of the keywords:
 # Options FileInfo AuthConfig Limit
 #
 AllowOverride None --> All  
. . .
</Directory>

【讨论】:

    猜你喜欢
    • 2017-10-17
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 2021-02-28
    • 2022-12-20
    相关资源
    最近更新 更多