首页 > 解决方案 > 如何从 litespeed 服务器上的 url 隐藏 index.php

问题描述

url -example.com/index.php
想要隐藏/index.php
htaccess已启用 - 其他一些规则有效

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L]

不起作用。index.php仍然存在
可能是因为我的服务器litespeed没有apache
任何帮助

标签: .htaccessredirectmod-rewriteurl-rewritinglitespeed

解决方案


根据您显示的示例,请尝试以下操作。

使用任一代码:

RewriteEngine ON
RewriteRule ^index\.php/?$ http://%{HTTP_HOST}/ [NC,R=301]
RewriteRule ^/?$ index.php [L]

或使用THE_REQUEST变量尝试:

RewriteEngine ON
RewriteCond %{THE_REQUEST} \sindex\.php\s [NC]
RewriteRule ^ http://%{HTTP_HOST}/ [NC,R=301]
RewriteRule ^/?$ index.php [L]

推荐阅读