【问题标题】:Remove index.php from routes in Lumen/Laravel从 Lumen/Laravel 中的路由中删除 index.php
【发布时间】:2016-05-16 03:10:17
【问题描述】:

我将我的 Lumen 项目移至 Ubuntu。

没有index.php,我无法访问定义的路由。

我可以通过这种方式访问​​路由:

public/index.php/api/user

我尝试了命令 a2enmod rewrite 并重新启动 apache2,但这对我不起作用。不知道是不是公共文件中的.htaccess文件。

有什么帮助吗?

【问题讨论】:

  • 您可能需要根目录或虚拟主机目录中的 Apache "AllowOverride All" 指令以允许 .htaccess 文件正常工作
  • 我放了 AllowOverride All 但不起作用,出现域错误。
  • 你是否在 apache config 中定义了文档根目录?请分享您的 apache 配置

标签: php .htaccess laravel ubuntu lumen


【解决方案1】:

将 public 文件夹中的 .htaccess 和 index.php 移动到项目的根文件夹 打开 index.php 然后重命名

$app = 需要 DIR.'/../bootstrap/app.php'; 到 $app = 需要 DIR.'/bootstrap/app.php';

注意,复制粘贴下划线符号时不会被复制。

【讨论】:

    【解决方案2】:

    把这个放在 .htaccess 中

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} /index [NC]    
    RewriteRule ^ / [R=302,L,NE]  
    

    看到这个how-to-remove-public-from-url-in-laravel
    还有这个Remove index.php from url Laravel 5

    【讨论】:

      猜你喜欢
      • 2018-04-27
      • 2014-08-26
      • 2015-11-17
      • 1970-01-01
      • 2018-03-04
      • 1970-01-01
      • 2017-01-28
      • 1970-01-01
      • 2014-05-15
      相关资源
      最近更新 更多