繁体   English   中英

在本地删除codeigniter的index.php

[英]Removing index.php of codeigniter on local

我正在尝试删除本地主机中的index.php,但它似乎不起作用,它位于http://localhost/testing

我将.htacces放在htdocs下的“测试”目录中。

Apache / conf上的LoadModule rewrite_module modules/mod_rewrite.so也已取消选中。

这是我的.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';

当我访问登录控制器时,找不到它。

未找到

在此服务器上找不到请求的URL / testing / login。

我真的不知道下一步该怎么做。 任何帮助,将不胜感激。

尝试这个 :-

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]

基本上index.php包含在所有URL中:

我们可以通过简单的规则使用.htaccess删除它。 以下是使用“负”方法进行重定向的所有文件的示例,

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

现在重新启动服务器并检查

您的htaccess应该像

RewriteEngine On
RewriteBase /testing/

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

无需附加/testing/因为RewriteBase已经解决了这一问题。

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']应为空白。

在.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

您的配置文件很好

区别在于“?” 在index.php之后

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM