-1

I have wabsite called vdo24.com ,it works with both www and non-www prefix. but i want redirect to http://vdo24.com from http://www.vdo24.com

i tried many combination in my .htaccess file : but non of this works ,i don't know why ?

1-->>
RewriteCond %{HTTP_HOST} !^vdo24\.com [NC]  
RewriteRule (.*) http://vdo24.com/$1 [QSA,R=301,L]`

2-->>
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
ketul shah
  • 413
  • 2
  • 7
  • 17

2 Answers2

0

This redirects whole domain to a non-www version:

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

Plus make sure you have rewrite engine turned on in your .htaccess file. All together with your domain is like this:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.vdo24.com [nc]
RewriteRule (.*) http://vdo24.com/$1 [R=301,L]
Mordor
  • 485
  • 2
  • 4
  • 14
  • it also doesn't work.?? chk it i just updated .htaccess with your code. – ketul shah Aug 09 '13 at 02:50
  • Then the problem is somewhere else (not in the code itself). Are you using some CMS? (Wordpress or something? You have to usually set this www to non-www in the administration CMS itself) Are you sure that your hosting provider allows you to use .htaccess file? (sometimes you have to ask your hosting provider to turn on that option for you). Is your .htaccess file located in the root directory of your website? – Mordor Aug 09 '13 at 03:00
0

Since you want a redirect, rather than just a URL rewrite, I would recommend the following:

Redirect permanent / http://vdo24.com/

It's simple and effective and will do exactly what you need.

Mike
  • 4,852
  • 1
  • 29
  • 48