Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect from www.domain.com to domain.com?

Tags:

apache

I am using the following code in my httpd.conf for redirections:

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

But, it ends up redirecting to www.domain.com/domain.com//domain.com//domain.com

I want all the following URLs to redirect to domain.com:

http://domain.com
http://www.domain.com
www.domain.com
like image 987
egidra Avatar asked May 19 '12 01:05

egidra


Video Answer


1 Answers

This should do it. The problem is that it looks pretty much like what you already have. When you type http://domain.com in your browser, does it work? Or does it redirect to somewhere else?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteRule ^(.*)$ http://domain.com$1 [R=permanent,L]
like image 166
Emmaly Avatar answered Sep 21 '22 08:09

Emmaly