You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在WordPress主站子目录部署Laravel站点遇404问题求助

在WordPress主站子目录部署Laravel站点时出现"页面未找到"错误

站点结构

  • 主站根目录(public_html)部署WordPress
  • Laravel文件存放于主站根目录的laravelfiles子目录,对外访问入口为laravelfiles/public

现有配置文件内容

主站根目录(public_html)的.htaccess

<IfModule security2_module>
    SecRuleRemoveByTag unoeuro
</IfModule>

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Laravel的public目录(public_html/laravelfiles/public)的.htaccess

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

    RewriteEngine On

    # 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>

Laravel的public/index.php代码

require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

Laravel的.env配置

APP_URL='https://mainsite/laravelfiles'
FRONTEND_URL='https://mainsite/laravelfiles/public'

问题描述

完成上述配置后,访问Laravel站点时始终显示"页面未找到"错误。已尝试修改.htaccess、.env、index.php文件,清除Laravel缓存等多种常见解决方案,但问题仍未解决。

内容的提问来源于stack exchange,提问作者Nabil Qazi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 04:16:06