删除index.php-官方指南不起作用(代码点火器) [英] Removing index.php - official guide not working (code igniter)
问题描述
我正在尝试删除Code Igniter网址中的index.php。根据官方指南,我应该将以下代码添加到.htaccess文件中。
I am trying to remove the index.php in the url for Code Igniter. According to the official guide, I should add the following code to the .htaccess file.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
这不起作用。
所以我进行了更多搜索,有人说我应该删除默认设置配置在索引页面上,所以我在config.php文件中进行了更改:
So I do more searches and some say that I should remove the default configuration on the index page, so I make the changes in the config.php file:
$config['index_page'] = '';
它仍然无法正常工作。然后,在更多搜索中,我发现了该代码的不同版本(例如,只是一个例子,我已经尝试了许多版本)
It is still not working. Then, on more searches, I found different version of the code, like this one (there is just an example, I have tried many version already)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
我最初将代码放在根目录的.htaccess中,但是由于无法正常工作,我也尝试将其添加到其他目录的.htaccess中。但是,仍然无法正常工作。
I initially put the code in the .htaccess of the root directory, but as it is not working, I also try adding it to .htaccess in other directory. Yet, still not working.
我只是使用默认的欢迎页面进行测试,因此我确定这不是编码问题。即
I am just using the default welcome page for testing, so I am sure it is not the problem of coding. i.e.
http://localhost/projectFolder/CodeIgniter/welcome/
有人知道我错过了什么吗?
Anybody got idea what have I missed?
推荐答案
我我假设 http:// localhost / projectFolder / CodeIgniter /
映射到的任何文件夹都是您的docroot,而 .htaccess
文件位于该目录内。
I'm assuming that whatever folder that http://localhost/projectFolder/CodeIgniter/
maps to is your docroot and that the .htaccess
file is inside that directory.
如果是这种情况,那么您的代码是正确的-因此,这取决于您的apache配置。通过更改目录块- AllowOverride All
,确保您允许 .htaccess
文件。
If that is the case, then your code is correct - so it's a matter of your apache config. Make sure that you are allowing .htaccess
files by changing the Directory block - AllowOverride All
.
这篇关于删除index.php-官方指南不起作用(代码点火器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!