是否有可能 ci url 不能与 index.php 一起使用。我不想在 url 中添加 index.php。如果有人在 url 中添加 index.php 它应该不起作用。我已经尝试了很多方法。请给我建议。 我已经尝试过了,但它不起作用
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
例如
如果我使用下面的 url 这应该可以工作......................
`example.com/abc`
如果我使用下面的 url 不应该工作
`example.com/index.php/abc`
最佳答案
在您的根目录中创建 .htaccess 文件并将此代码保存在其中
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
打开application/config/config.php
//find the below code
$config['index_page'] = "index.php"
//replace with the below code
$config['index_page'] = ""
/find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
关于php - ci url 是否可能不适用于 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51665022/