Re-direct issues

edited October 2012 in Installation
I've added the piece of code below to re-direct non-www URL's to www URL's.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

The homepage is re-directing fine but the pages are not. When I enter it re-directs to

For some reason it's adding index.php in the URL's only when the pages are re-directed to the www. version.

Thanks in advance for any help on this problem.


  • edited 7:34PM
    Hmm... I've used that code as well and haven't seen that problem. Is this before the other rewrite rules? Also, is the "index_page" value set to blank in the main CI config file (fuel/application/config/config.php)? Below is an example of a .htaccess file that has worked for us:
    Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On # for www redirect RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteBase / <Files .*> Order Deny,Allow Deny From All </Files> # Allow asset folders through RewriteRule ^(fuel/modules/(.+)?/assets/(.+)) - [L] # Protect application and system files from being viewed RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+) - [F,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [L] # Prevents access to dot files (.git, .htaccess) - security. RewriteCond %{SCRIPT_FILENAME} -d RewriteCond %{SCRIPT_FILENAME} -f RewriteRule "(^|/)\." - [F] </IfModule> Options -Indexes
Sign In or Register to comment.