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

时间:2019-02-14 11:22:41

标签: php codeigniter godaddy-api

我无法从URL中删除文件扩展名

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

这是我网站的当前URL

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

请帮帮我吗?

4 个答案:

答案 0 :(得分:1)

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

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

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

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

答案 1 :(得分:0)

您可以使用以下方法删除:

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

答案 2 :(得分:0)

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

答案 3 :(得分:0)

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

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

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