Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

How to create .htaccess file for 301 permanent redirect. I am looking for exact code that we would put in the file.

Looking forward to hear from you all.

Thanks in advance.

share|improve this question

migrated from Jun 17 '10 at 11:47

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Chris S Feb 17 '12 at 16:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I suggest Googling before searching here:… – Kerry Jones Jun 17 '10 at 6:41

This look like it.

Redirect permanent /oldpage.html
Redirect 301 /oldpage.html

For Apache after around version 2.2.14

share|improve this answer

If you don't have a .htaccess file (for instance, on a Windows server) it's possible to redirect individual html pages using a meta tag:

<meta http-equiv="refresh" content="0;url=">

This goes in the section along with the other meta tags. The content="0; tells the browser to redirect as sson as the page loads (this can be set to delay for a number of seconds), and the rest of the tag is the URL of the new page.

This isn't the best solution, since it has to be put into every page, and dynamic pages (eg php pages) have better ways to do this.

share|improve this answer