skip to Main Content

Hay, In Plesk it gives me the ability to add a subdomain to a domain say x.y.com, the problem is that www.x.y.com gets treated as another subdomain. Is there a way to direct all traffic from www.x.y.com to x.y.com? I tried doing this in php using the 300 header, but stuff like www.x.y.com/mypage, doesn’t get redirected. Could i use the .htaccess file to redirect all this traffic?

Thanks

3

Answers


  1. # you probably want www.example.com to forward to example.com -- shorter URLs are sexier.
    # no-www.org/faq.php?q=class_b
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
      RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    </IfModule>
    

    Source: http://html5boilerplate.com

    Login or Signup to reply.
  2. Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^www.domain.com [nc]
    rewriterule ^(.*)$ http://domain.com/$1 [r=301,nc]
    

    From: http://www.webconfs.com/how-to-redirect-a-webpage.php

    Login or Signup to reply.
  3. RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.x.y.com [NC]
    RewriteRule ^(.*)$ http://x.y.com/$1 [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search