Welcome Guest, Not a member yet? Register   Sign In
CodIgniter and htaccess rewrite rule question
#1

[eluser]felyx[/eluser]
Well I have the following htaccess file and it is working fine but I will explain below what my problem is.

Code:
RewriteEngine on
# RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /index.php?/$1 [L]

What my problem is that I want to redirect http://www.somesite.com to http://somesite.com without ruining my actually working htaccess file/website. Anyone can give me a little help how could I put this rewrite rule into my htacces file without causing trouble?
Thank you in advance!
#2

[eluser]pickupman[/eluser]
Add this below RewriteEngine On
Code:
RewriteCond %{HTTP_HOST} !^www.somesite.com$ [NC]
RewriteRule ^(.*)$ http://www.somesite.com/$1 [L,R=301]
#3

[eluser]felyx[/eluser]
[quote author="pickupman" date="1284403007"]Add this below RewriteEngine On
Code:
RewriteCond %{HTTP_HOST} !^www.somesite.com$ [NC]
RewriteRule ^(.*)$ http://www.somesite.com/$1 [L,R=301]
[/quote]

Thank youvery much it works!
#4

[eluser]12vunion[/eluser]
Add a line below RewriteEngine on
Code:
#no WWW
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

The reverse also works
Code:
#Force WWW
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]




Theme © iAndrew 2016 - Forum software by © MyBB