301 redirect in xhtml css website - how to

Discussion in 'HTML & Website Design' started by cri8bat, Nov 20, 2012.

  1. #1
    I can only code xhtml and css.

    I am almost finished coding my website that has over 15 pages. I want to submit the xml sitemap to webmasters tool.
    however how do I make sure that http://www.domain.com is default.

    let me explain, if someone types domain.com instead of www.domain.com it will always redirect to www.domain.com

    I dont want to split page rank juice.

    I think is done by .htaccess however as I said the website is pure xhtml and css. Not a CMS where you have to activate the .access file
    how do you activate this file in pure xhtml css website and how do you write this code?
     
    cri8bat, Nov 20, 2012 IP
  2. ntmedia

    ntmedia Active Member

    Messages:
    118
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    90
    #2
    you can't use xhtml to make such redirects. You must use .htaccess

    This code would add www. if someone enters a site without www.
    I use this code at my site - ntmedia.me (test it to see if that's what you're looking for, although I've also got /en to add by default)

    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.domain.com$
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    
    Code (markup):
     
    ntmedia, Nov 20, 2012 IP