从 silex 中的 url 中删除脚本文件名



我正在尝试使用 htaccess 从 URL 栏中删除索引.php脚本名称。这是我的htaccess文件:

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^ index.php [QSA,L]    
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteRule ^(.*)$ https://website.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.website.com$
RewriteRule (.*) https://website.com/$1 [R=301,L]
</IfModule>

但仍然是 URL 中的索引.php如下所示:https://website.com/index.php/url,需要移动到 https://website.com/url

使用以下代码解决:

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s(.*)/index.php [NC]
RewriteRule ^ %1 [R=301,L]
</IfModule>

最新更新