Welcome Guest, Not a member yet? Register   Sign In
.htacces redirect loop non-www
#1

[eluser]Unknown[/eluser]
Hi Codeigniter community!

I´ve been this .htaccess and all works OK! but i want to redirect always to a www. site not to non-www site

This is .htaccess that remove index.php and works OK
Code:
RewriteEngine On

#This bit does the codeigniter magic
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

But if i try with this:

Code:
RewriteEngine On

#This bit rewrites your host name to include www
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]

#This bit does the codeigniter magic
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Server says me that i´ve got a redirect loop.

How can i redirect to www site and remove index.php?

thanks
#2

[eluser]CroNiX[/eluser]
Try
Code:
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
#3

[eluser]Unknown[/eluser]
Thanks for you answer but it says same message, redirect loop...
#4

[eluser]CroNiX[/eluser]
Does your base_url setting in CI contain the www?
#5

[eluser]CroNiX[/eluser]
Also might try clearing your browser cache in between tests while you are working on this.




Theme © iAndrew 2016 - Forum software by © MyBB