首页 > 解决方案 > 当 index.php 不在 URL 中时,Laravel 8 强制下载而不是在 wamp 上执行 PHP 文件

问题描述

我正在处理我在 WAMP 上的一个项目,现在在域上有一个副本。一切都在网上运行良好,直到最近在 wamp 上运行良好,但从昨天开始我遇到了以下问题:

- 该项目位于 http://localhost/control/public/ ,它显示了登录页面(那里一切正常) - 一旦登录,用户将被重定向到 http://localhost/control/public/cp,这也有效很好,它在 http://localhost/control/public/index.php/cp 也可以正常工作 - 我还有其他页面,例如用于用户管理的部分。如果我使用 URL http://localhost/control/public/index.php/cp/admin/users 它工作正常但是如果我从 URL 中删除 index.php 到 http://localhost/control/public/cp /admin/users 我下载了一个文件(包含 public/index.php 的内容) - 其他一些路由适用于两个版本的 URL(有和没有 index.php),如果 index.php 其他人将推送下载不在网址中。

我找不到这背后的任何逻辑,我猜它可能来自 .htaccess 并且已经看到我可以添加一个 rewriteBase 但我得到了相同的问题。这是我的.htaccess:

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    RewriteBase /control/public/

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

任何指针将不胜感激

标签: laravelwampwampserver

解决方案


推荐阅读