如何使用 .htaccess 从 URL 中删除文件扩展名 (index.php )

How to remove File Extension (index.php ) from URL using .htaccess

我无法从 URL

中删除文件扩展名

https://www.deemsolar.com/ar/index.php

这是我网站的当前 URL

我想将其更改为 https://www.deemsolar.com/ar/

请帮帮我好吗?

您可以删除使用:

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

完整、清晰地阅读文档。 codeigniter urls docs

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ .php [NC,L]

# For Index
RewriteRule ^index.extension?$ /index.php [NC,L]

# For Another Page
RewriteRule ^login.extension?$ /login.php [NC,L]

将此添加到您的 .htaccess 文件中

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

注意:确保在 config.php 文件中,

$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";