CyberPanel之伪静态规则略解

CyberPanel使用了OpenLiteSpeed(OLS)为web服务器,OLS可以兼容apache的.htaccess文件,但是略有不同

主要差别为 OLS需要添加一个斜杆(/)
《CyberPanel之伪静态规则略解》
比如 WordPress自带的.htaccess内容为

1
2
3
4
5
6
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

然而这份规则并不完全兼容OLS,开启固定链接后会导致404错误。

此时应当修改规则为

1
2
3
4
5
6
RewriteEngine On
RewriteBase /
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

注意第三行的代码
原代码为:RewriteRule ^index\.php$ – [L] ,修改为 RewriteRule ^/index\.php$ – [L]

唯一的差别就是那个加粗的斜杆(/)

注意修改后需要重启OLS以生效。

点赞

发表评论

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