我的codeiginter项目在没有index.php的情况下无法在线工作

时间:2016-04-26 09:41:01

标签: .htaccess codeigniter cpanel

我的Codeigniter项目在localhost(我正在使用linux Cpanel)中运行良好

https://localhost/project/profile

但是如果链接中没有index.php则无法在线工作

https://domainname.in/index.php/profile

.htaccess文件

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

和我的 route.php 文件

$route['default_controller'] = "pages/home";
$route['404_override'] = '';
$route['pages/profile'] = "pages/profile"; 
$route['creators'] = "pages/userList";
$route['auth/logout'] = "auth/logout";
$route['auth'] = "auth/logout";
$route['auth/login'] = "auth/login";
$route['auth/register'] = "auth/register";
$route['pages/post'] = "pages/post";
$route[$username.'/about'] = "pages/menus/about";
$route[$username.'/credibility'] = "pages/menus/credibility";
$route[$username.'/release'] = "pages/menus/release";
$route[$username.'/jobs'] = "pages/menus/jobs";
$route[$username] = "pages/userList/userview/$1";   

2 个答案:

答案 0 :(得分:0)

请尝试这个。希望它能奏效。

使用根.htaccess.txt文件进行更新

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 
Options All -Indexes

答案 1 :(得分:0)

在项目文件夹中创建.htaccess文件,希望它能正常工作。

RewriteEngine on
RewriteBase /projectfoldername/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|js|img|css|captcha|robots\.txt)
RewriteRule ^(.*)$ /projectfoldername/index.php/$1 [L]