简体   繁体   English

Codeigniter URL重写不适用于找不到对象错误

[英]Codeigniter URL rewrite not working with object not found error

I am new to codeigniter. 我是Codeigniter的新手。 I tried to use the url rewrite in my local server to hide index.php folder but it show object not found error when i try to access any controllers. 我试图在本地服务器中使用url重写来隐藏index.php文件夹,但是当我尝试访问任何控制器时它显示未找到对象错误。 or example users/login is not working whereas index.php/users/login is working how to fix it. 或示例用户/登录不起作用,而index.php / users / login正在修复该问题。

The details are application directory -> f:xampp/htdocs/testapp/application/controllers/users 详细信息是应用程序目录-> f:xampp / htdocs / testapp / application / controllers / users

in config.php -> $config['index_page'] = 'index.php'; 在config.php-> $config['index_page'] = 'index.php';

in routes -> $route['default_controller'] = "users"; 在路由中-> $route['default_controller'] = "users";

.htaccess rule - .htaccess规则-

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Deny from all

working url - 工作网址-

localhost/bluechip/index.php/users/login 本地主机/蓝筹股/ index.php文件/用户/登录

Not working - 无法运作-

localhost/bluechip/users/login 本地主机/蓝筹股/用户/登录

In config use 在配置中使用

$config['index_page'] = '';

And use the following .htaccess - 并使用以下.htaccess-

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

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

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