我有一个CI路径
$route['signin']="auth/login";
$route['logout']="auth/logout";
$route['signup']="auth/register";
我的ci安装位于www.domain.com/app/
当我转到此网址时,它会路由到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安装在另一台服务器上,我把它转移到这个新服务器上。我把基本网址留空了。
htaccess代码是
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
答案 0 :(得分:2)
此ci安装在另一台服务器上,我将其转移到这台新服务器。
基于它在另一台服务器上工作,似乎新服务器没有配置{hmpaccess {h}启用htaccess的AllowOverride
Apache设置,这意味着您的htaccess已被禁用或被忽略。或者新服务器是非Apache Web服务器,根本无法识别htaccess。
答案 1 :(得分:1)
您需要将 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]
答案 2 :(得分:0)
试试这个:
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/