Reputation: 3324
My htaccess right now:
# Use PHP 5.3
AddType application/x-httpd-php53 .php
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#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]
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
I need to do a rule, that if somebody type http://www.mypage.com/blog/blablatitle
it redirects him to http://mypage.com/blog/blablatitle
and the same for the frontpage and all pages.
I am using CodeIgniter, but I think this is not so important when dealing with htaccess.
This suggested solution is not working well in CodeIgniter:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Because it adds index.php in the address e.g.: when I type:
http://www.mypage.com/blog/blablatitle
it redirects me to:
http://mypage.com/index.php?/blog/blablatitle
And I need:
http://mypage.com/blog/blablatitle
Without this rule it is ok (without index,php) e.g.: http://mypage.com/blog/blablatitle
So, any advice how to improve this redirect rule som index.php doesn't appear in the redirected link?
Upvotes: 0
Views: 3115
Reputation: 865
Try this please:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^index.php(.*)$ http://%1/$1 [R=301,L]
Upvotes: 1