This is one of those entries I make after finally learning how to do something I've wanted to know how to do for awhile. I make these entries for two reasons: 1) it's theoretically possible I might forget what I learned, and 2) someone else might have been wondering the exact same thing, and if I had difficulty finding a place where the information was spelled out (no matter how available and easy to find the information might actually be), I think it's possible someone else might have had the same difficulty.
If you go to http://en.wikipedia.org/ (for example), you'll be redirected to http://en.wikipedia.org/wiki/Main_Page. I know how to use HTML to make one page redirect to another, but it's flaky and seems to require a time-delay. (Changing the time-delay to 0 seems to work with some browsers and give seizures to others. Probably something I'm doing wrong.) And if you dig into the internals of an HTTP session with port 80 on en.wikipedia.org, you'll see that what it's doing isn't anything like sending an HTML document with redirect information.
So here's how to do exactly what Wikipedia (and probably trillions of other sites) does: create (if it doesn't exist) the
Redirect 301
/index.html http://destination.site.example.com/path/to/page/
If you leave out the 301, the browser will be told the page has moved temporarily. If you include the 301, the browser will be told the page has moved permanently.
Not quite (Score:2)
Re:Not quite (Score:2)
Ah, I see. The trailing slash in my example does indeed cause that problem (which I also discovered when I was trying to get this to work, and I simply redirected / to /dir/). In the real-life versions I set up tonight, this wasn't an issue.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Pointless redirects (Score:2)
Even worse, visitors will bookmark the URL they get redirected to and start linking to that, and then six months later when the site changes to some other software the URL will stop working and the web will be filled with broken links to the site. (Not that that's likely to happ
Re:Pointless redirects (Score:2)
Wikipedia may have its reasons, but there are far too many sites that redirect their front pages to some other URL. Why can't these people just set up their servers to give me the right content when I ask for "/" in the first place?
In my case it's because I'm using a cheapo hosting service and don't have that kind of access to the server.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Re:Pointless redirects (Score:2)
Redirectin anDirectoryIndexinsideRe:Pointless redirects (Score:2)
Thank you. I will look into those to see if they better provide what I want.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers