简体   繁体   中英

codeigniter work only with index.php in the url

I have a CI installation which has routes

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

my ci installation resides inside www.domain.com/app/

when i goto this url , it routes to www.domain.com/app/signin/ but it shows

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

but when i manually insert index.php

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

then it opens.

What can be the issue?I have configured htaccess.

This ci installation was in another server and I transafered it to this new server.I kept the base url blank.

htaccess code is

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.

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. Or the new server is a non-Apache web server, which doesn't recognize htaccess at all.

You need update config.php to this

/*
|--------------------------------------------------------------------------
| 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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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