简体   繁体   English

codeigniter仅适用于URL中的index.php

[英]codeigniter work only with index.php in the url

I have a CI installation which has routes 我有带有路由的CI安装

$route['signin']="auth/login";
$route['logout']="auth/logout";
$route['signup']="auth/register";

my ci installation resides inside www.domain.com/app/ 我的ci安装位于www.domain.com/app/

when i goto this url , it routes to www.domain.com/app/signin/ but it shows 当我转到此url时,它路由到www.domain.com/app/signin/,但显示

The requested URL /www.domain.com/app/signin was not found on this server.

but when i manually insert index.php 但是当我手动插入index.php时

www.domain.com/app/index.php/signin

then it opens. 然后打开。

What can be the issue?I have configured htaccess. 可能是什么问题?我已经配置了htaccess。

This ci installation was in another server and I transafered it to this new server.I kept the base url blank. 此ci安装在另一台服务器上,我将其转移到该新服务器上。我将基本url保留为空白。

htaccess code is htaccess代码是

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

This ci installation was in another server and I transferred it to this new server. 此ci安装在另一台服务器上,我将其转移到了新服务器上。

Based on it working on another server, it appears the new server does not have the AllowOverride Apache setting configured to enable the htaccess, meaning your htaccess is disabled or ignored. 基于它在另一台服务器上的工作情况,新服务器似乎没有配置AllowOverride Apache设置来启用htaccess,这意味着您的htaccess被禁用或忽略。 Or the new server is a non-Apache web server, which doesn't recognize htaccess at all. 或者,新服务器是非Apache Web服务器,它根本无法识别htaccess。

You need update config.php to this 您需要将此更新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

Now .htaccess 现在.htaccess

RewriteEngine on

# RewriteBase /
RewriteBase /app/

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

Try this : 尝试这个 :

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]

set RewriteBase like this RewriteBase/app/ 像这样设置RewriteBase RewriteBase/app/

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

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