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

Laravel应用Apache Rewrite Engine路由冲突问题求助及解决

Laravel路由异常:/publicaties被重写为/public的问题排查与解决

问题情况

使用Laravel开发Web应用,临近完成时遇到路由异常:访问http://example.org/publicaties(荷兰语“publication”)时,被Apache Rewrite引擎错误重写为http://example.org/public。当前使用的是Laravel默认的Rewrite规则配置。

所用Rewrite规则配置

DirectoryIndex index.php
<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对相似名称的路由(如publicaties与publications)存在兼容冲突,修改URL路径后,异常情况消失。

内容的提问来源于stack exchange,提问作者Daan Verhelst

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 07:10:33