Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com 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: google.com/… –  Kerry Jun 17 '10 at 6:41

2 Answers 2

This look like it.


Redirect permanent /oldpage.html http://www.example.com/newpage.html
Redirect 301 /oldpage.html http://www.example.com/newpage.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=http://www.example.com/newpage">

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