codeigniter只能与url中的index.php一起工作

codeigniter只能与url中的index.php一起工作,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我有一个有路由的CI安装 $route['signin']="auth/login"; $route['logout']="auth/logout"; $route['signup']="auth/register"; 我的ci安装位于www.domain.com/app/ 当我转到此url时,它会路由到www.domain.com/app/signin/但它会显示 The requested URL /www.domain.com/app/signin was not found on th

我有一个有路由的CI安装

$route['signin']="auth/login";
$route['logout']="auth/logout";
$route['signup']="auth/register";
我的ci安装位于
www.domain.com/app/

当我转到此url时,它会路由到www.domain.com/app/signin/但它会显示

The requested URL /www.domain.com/app/signin was not found on this server.
但是当我手动插入index.php时

www.domain.com/app/index.php/signin
然后它打开了

可能是什么问题?我已配置htaccess

此ci安装在另一台服务器中,我将其传输到新服务器。我将基本url保留为空

htaccess代码是

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

您需要更新config.php,以实现此目的

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://domain.com/app/';

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = ''; // Remove index.php
现在.htaccess

RewriteEngine on

# RewriteBase /
RewriteBase /app/

RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
此ci安装在另一台服务器中,我已将其转移到新服务器

基于它在另一台服务器上的工作情况,新服务器似乎没有配置Apache设置以启用htaccess,这意味着您的htaccess被禁用或忽略。或者新服务器是非Apache web服务器,根本无法识别htaccess。

请尝试以下操作:

RewriteEngine on
RewriteBase/app/

# Add www in the start of URL if user leave
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Prevent CI index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

# Prevent user access to the CI system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Prevent user access to the CI application folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

设置
RewriteBase
如下
RewriteBase/app/

其中是.htaccess代码逐步解决方案:@user3637105检查答案有时这取决于您的托管服务器。请你提一下你的主机服务器提供商的名字。那么你的.htaccess看起来不错。您可能还有其他问题。我的问题是apache。那么如何启用htaccess?有吗?单击答案中的
AllowOverride
链接了解如何启用它。要授予htaccess的完全访问权限,请在httpd.conf文件(在
部分)中使用
AllowOverride All