laraval 伪静态去掉index.php

laraval  伪静态去掉index.php

有向chagpt  gemini  deepseek提出这个问题

给出的答案都不是很靠谱

只有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]

这个是最终正确的。

Previous Article

关于wordpress更换域名

Next Article

nginx-sxg-module安装配置

Write a Comment

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨