Created
April 1, 2012 04:59
-
-
Save ssokolow/2271546 to your computer and use it in GitHub Desktop.
Redirecting when the old URL may or may not support .htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The proper way to HTTP Redirect... but not all hosts listen to .htaccess (eg. GitHub Pages) | |
# Some hosts also provide a special redirect option in their hosting controls. | |
RedirectPermanent / http://www.newsite.com/ | |
# Probably never used, but just to be thorough. | |
ErrorDocument 404 /404.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- | |
Custom 404 page. (GitHub Pages version) | |
This will provide a last-ditch protection against broken links for actual users. | |
However, search engines won't recognize it as a redirect. Hence why index.html is necessary. | |
IMPORTANT: You should also activate your old site in Yahoo and Google Webmaster Tools. | |
That will allow you to file a change of address notification in their search indexes | |
for all pages within your domain. | |
--> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<script type="text/javascript"> | |
var NEW_HOST = 'www.newsite.com'; | |
location.replace(location.protocol + '//' + NEW_HOST + location.pathname + location.search + location.hash); | |
</script> | |
</head> | |
<body> | |
<noscript><p>This content has moved. Please replace the <code>http://www.oldsite.com/</code> portion of | |
the address in your address bar with <code>http://www.newsite.com/</code>.</p></noscript> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- | |
The less-than-ideal way to redirect that relies on the browser rather than the server. | |
Requires a browser or other compatible User Agent and only covers the site root, | |
but Google and Yahoo treat it as equivalent to a proper HTTP 301 redirect. | |
Source: http://sebastians-pamphlets.com/google-and-yahoo-treat-undelayed-meta-refresh-as-301-redirect/ | |
--> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="refresh" content="0;url=http://www.newsite.com/" /> | |
</head> | |
<body> | |
<p>This content has moved to <a href="http://www.newsite.com/">http://www.newsite.com/</a>. Attempting to automatically redirect you.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment