删除index.php - 正式指南不工作(代码点火器) [英] Removing index.php - offical guide not working (code igniter)
问题描述
我试图删除代码Igniter的url中的index.php。根据官方指南,我应该添加以下代码到.htaccess文件。
RewriteEngine on
pre>
RewriteCond $ 1 !^(index\.php | images | robots\.txt)
RewriteRule ^(。*)$ /index.php/$1 [L]
这不工作。
所以我做更多的搜索,有些人说我应该删除默认因此我在config.php文件中进行更改:
$ config ['index_page'] = '';
它仍然不工作。然后,在更多的搜索,我发现不同版本的代码,像这样(只有一个例子,我已经尝试过许多版本)
RewriteEngine on
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule。* index.php / $ 0 [PT,L]
我最初将代码放在根目录的.htaccess中,但由于它不工作,我也尝试将其添加到.htaccess在其他目录。但是,仍然无法正常工作。
我只是使用默认的欢迎页面进行测试,所以我相信这不是编码的问题。即
http:// localhost / projectFolder / CodeIgniter / welcome /
pre>
任何人都知道我错过了什么?
解决方案'm假设
http:// localhost / projectFolder / CodeIgniter /
映射到的任何文件夹是您的docroot,并且.htaccess
文件在该目录中。
如果是这种情况,那么你的代码是正确的 - 所以这是一个apache配置的问题。确保您通过更改目录块 -
AllowOverride All
允许.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]
This is not working.
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]
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?
解决方案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.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
.Take a look at this page for help doing that.
这篇关于删除index.php - 正式指南不工作(代码点火器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!