2013-10-19 51 views
0

我想删除index.php,在我的本地主机,但它似乎不工作,它的http://localhost/testing删除本地codeigniter index.php

我把.htacces放在htdocs下的'testing'目录下。

LoadModule rewrite_module modules/mod_rewrite.so 在Apache/conf上也没有选中。

这里我的.htaccess:

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

这里我的配置:

$config['base_url'] = "http://localhost/testing"; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

当我访问登录控制器,它没有找到。

未找到

所请求的网址/测试/登录此服务器上未找到。

我真的不知道接下来要做什么。任何帮助,将不胜感激。

+0

有没有其他设置? –

回答

0

基本的index.php包含在所有的网址:

,我们可以使用.htaccess文件用一个简单的规则删除此。下面是此类文件的一个例子,使用“负”的方法中,一切都被重定向,

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

立即重新启动服务器,并检查

+0

感谢您的答案,我尝试了,但它仍然无法工作 –

0

htaccess应该像

RewriteEngine On 
RewriteBase /testing/ 

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

没有必要追加/testing/,因为RewriteBase已经处理好了。

+0

感谢您的答案,我尝试了,但它仍然无法工作 –

+0

@AldiAryanto将'base_url'设置为'http:// localhost /' 。 –

+0

仍然不能正常工作:( –

1

试试这个: -

的config.php: -

$config['base_url'] = 'http://localhost/testing/'; 

$config['index_page'] = ''; 

的.htaccess

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

谢谢你的回答,我尝试了,但它仍然不能工作 –

0

留出RewriteBase结尾的斜线:

RewriteEngine On 
RewriteBase /testing 

RewriteCond $1 !^(index\.php|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 

$config['base_url']应该是http://localhost/testing/

$config['index_page']应该是空白的。

0

试试这个.htaccess文件中: “?”

RewriteEngine on 
RewriteCond $1 !^(index\.php|robots\.txt|resources) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L] 
ErrorDocument 404 /mainpage 

您的配置文件是好的

区别在于指数后。php

0

您可能还想尝试更改./application/config/config.php中的$config[‘uri_protocol’]的值。有时CodeIgniter会错误的。将其更改为PATH_INFO可能有效。