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 thehttp://intranet/trunk/index.php/class
on the old se开发者_开发技巧rver
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.
精彩评论