|
|
RedirectsImagine you have a file named: jasons-idea-of-a-god-time.html After some time you realize that its wrong and you want to change it to
jasons-idea-of-a-good-time.html. What would happen to all the people who
bookmarked the page and everyone finding the page via a search engine? Don't
worry. With a simple redirect the problem can be solved. The Apache web server provides several ways for setting up redirects for different reasons. The most simple one is using the “Redirect” directive:
If you include this line in your .htaccess file, a visitor trying to go to http://www.domain.com/oldfolder will be automaticly redirected to http://www.domain.com/newfolder with out him ever knowing it. Since the search engines get tougher everyday, now we have "permanent redirects" too. The status code of a permament move is 301. In .htaccess it would be something like this:
Another useful use is the RedirectMatch. With it you can use regular expressions in the redirect condition. For example:
In this case, this line of code will redirect any and all visitors looking for a .html file into a .php file. When can this happen? Say you start your website with a regular .html file. In time, youll probably get somewhat familiar with CMS (Content Management System) that used PHP. Your pages would no longer be .html, they would end in .php. All bookmarks would suddenly work again. There is another way, more powerful and more complex called ModRewrite, but we will talk about it later. Review It
|
|
||||||||||