laraval 伪静态去掉index.php

原创
ilancing 2周前 (07-18) 阅读数 25 #WEB技术

laraval  伪静态去掉index.php

有向chagpt  gemini  deepseek提出这个问题

给出的答案都不是很靠谱

image.png

只有deepseek给出可能解决的思路 顺着这个思路问了三个最终给出正常答案:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php(?:/|\?)(.*)?\ HTTP/

RewriteRule ^index\.php$ / [R=301,L]

RewriteRule ^(.*)index\.php/(.*)$ /$1$2 [R=301,L]

RewriteRule ^(.*)index\.php\?(.*)$ /$1?$2 [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/$ /$1 [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]


这个是最终正确的。

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权本站发表,未经许可,不得转载。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。