简体   繁体   中英

Codeigniter removing /index.php/class

I've moved all of a local intranet site onto a new server with a new dns. Everything seems to be working fine after changing setting and config files.
The only thing that is annoying me is that I can't get rid of the

http://intranet/trunk/index.php/class on the old server

http://intrenet/trunk/class 

worked fine, but now it throws up

The requested URL /trunk/class/ was not found on this server.

But as I said, works fine when using the /index.php/class . This should be fixable in the .htdocs (which I have put in the trunk folder, is that wrong?)

I've changed all the codeigniter configs too.

First make sure that URL-Rewriting (mod_rewrite) is enabled in your web server. Then create a .htaccess file in your htdocs directory with the below code.

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

and also edit config.php and remove the index.php 在此处输入图片说明

I had the same problem and i resolved with this .htaccess file

# Mod Rewrite active
<IfModule mod_rewrite.c>
    # Set base path
    RewriteEngine On
    RewriteBase /Workspace/codeigniter/

    # Denied access to system directory
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Denied access to application directory
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Check for error request
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

# Mod Rewrite inactive
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

Remember to set

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

in the config/config.php file and to change the path of the "RewriteBase" var.

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