Redirect index.php in CodeIgniter

Posted by Gabriel Bianconi on Stack Overflow See other posts from Stack Overflow or by Gabriel Bianconi
Published on 2010-05-18T22:37:46Z Indexed on 2010/05/18 22:40 UTC
Read the original article Hit count: 640

Filed under:
|
|

Hello.

I created a CodeIgniter application and now I'm trying to redirect the urls with index.php to urls without it.

My current .htaccess is:

RewriteEngine On
RewriteBase /

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

# Enforce www
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.plugb.com/$1 [L,R=301]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

The only problem is that the same page is accessible with and without the index.php.

For example:

http://www.plugb.com/index.php/games/adventure-rpg

and

http://www.plugb.com/games/adventure-rpg

Is there a way to redirect the index.php URLs?

Thank you, Gabriel.

© Stack Overflow or respective owner

Related posts about php

Related posts about .htaccess