Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

The ultimate xHTML / DHTML / HTML 301 redirection thread!

XHTML DHTML HTML dhtml xhtml redirect

  • This topic is locked This topic is locked
5 replies to this topic

#1 Dan

Dan

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 140 posts

Posted 28 June 2006 - 04:58 PM

If you don't know what a HTML/xHTML/DHTML 301 redirect is, you will by the end of this thread! If you need to redirect a page, unfortunately it isn't as simple as using one of the various methods - only the 301 redirect will preserve search engine rankings for the page. It is the most efficient, search engine friendly method for website redirection - the code 301 is interpreted as "moved permanently".

Here is how to perform a 301 redirect in the 3 afformentioned coding languages:

HTML, xHTML, DHTML:

  • Create a .htaccess file by opening up notepad, or a similair text/txt editor and save the file as .htaccess with no extension.
  • Place this code in your .htaccess file:

    redirect 301 /old/old.htm http://www.yoursite.com/new.htm

    OR, if you are redirecting to a new url, you need the following code:

    redirect 301 / http://www.yoursite.com/new.htm

    If you already have one of these files - make sure you leave a line before adding the code!

  • Save the file and upload to your server root folder.


  • Test the redirect works by visiting the old page - you should automatically be redirected!

  • 0

#2 brackett

brackett

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 192 posts

Posted 04 July 2006 - 05:58 AM

Actually, that's webserver dependent. The .htaccess trick is Apache only. IIS can do similar, but you need to use the IIS manager and set it...I don't recall the specifics right now, but basically right click the website/folder/file and there's a redirect tab I think.
  • 0

#3 Dan

Dan

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 140 posts

Posted 04 July 2006 - 06:17 AM

Actually, that's webserver dependent. The .htaccess trick is Apache only. IIS can do similar, but you need to use the IIS manager and set it...I don't recall the specifics right now, but basically right click the website/folder/file and there's a redirect tab I think.


Apologies yes, I should have stipulated that this would only work on Apache.

See the asp thread for IIS, I don't have much experience of windows servers so wouldn't know the trick above - is it a 301 redirect?
  • 0

#4 DevilsCharm

DevilsCharm

    Programming God

  • Just Joined
  • PipPipPipPipPipPip
  • 858 posts

Posted 04 July 2006 - 10:25 AM

301 redirects are useful, but isn't there another way to do a redirect that isn't called a 301 redirect? I think there is another way, or maybe I'm just thinking of something else.
  • 0

#5 Dan

Dan

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 140 posts

Posted 04 July 2006 - 02:18 PM

301 redirects are useful, but isn't there another way to do a redirect that isn't called a 301 redirect? I think there is another way, or maybe I'm just thinking of something else.


There are plenty of other ways of doing it through javascript etc.

However, only a 301 redirect should be used as this is the best for search engine optimisation. A 301 redirect is favoured by the search engines and wont lose existing pagerank.
  • 0

#6 brackett

brackett

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 192 posts

Posted 04 July 2006 - 02:57 PM

Apologies yes, I should have stipulated that this would only work on Apache.

See the asp thread for IIS, I don't have much experience of windows servers so wouldn't know the trick above - is it a 301 redirect?


Yes, IIS can generate both 301 (permanent) or 302 (temporary) redirects. http://support.micro...;313074&sd=tech
  • 0





Also tagged with one or more of these keywords: XHTML, DHTML, HTML, dhtml, xhtml, redirect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download