【问题标题】:Htaccess works with Apache but with litespeed doesnt workHtaccess 与 Apache 一起工作,但与 litespeed 不工作
【发布时间】:2026-01-16 10:50:02
【问题描述】:

这是我的 htaccess 代码。它适用于 Apache,但适用于 Litespeed 不能正常工作。我想将所有 html 和 php 文件放到 index.php 但在 Litespeed 中,

/example *works, there is no file which named example*
/folder/example.php *works, there are folder and example.php*
/folder/index.php *works, there are folder and index.php*
/folder/ *doesn't works, there is folder and there is index.php in this folder but its not redirect to main index*

所以 /folder/index.php 有效,/folder/ 无效。但它们是相同的东西。 htaccess 不理解文件夹是 Litespeed 中的一个 php 文件。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-\s]+)/?$ index.php?url=$1 [NC,L,QSA]
RewriteRule ^(.*?\.(?:html?|php))$ index.php?url=$1 [QSA,L,NC]

【问题讨论】:

    标签: php .htaccess litespeed


    【解决方案1】:

    删除怎么样

    RewriteCond %{REQUEST_FILENAME} !-d 它可以防止 /folder/ 被第一个重写规则重写。

    【讨论】:

    • 感谢您的帮助,但是当我删除此代码时,它不起作用。