There are several ways to do a page refresh or redirect it to a new one. It can be done in the client side, with HTML or a script language, or in the server side with PHP or in the server configuration directly. The most simple way is using the HTML to tell to the browser what to do, using a meta tag. Besides, the are many simple hosting services that don’t support server side scripting or don’t let clients to change the servers configuration (in apache this can be done with an .htaccess file).

This feature can be very helpful, besides it’s very easy to use. Imagine that we have a website with several languages organized in a folder structure with the language codes. We’ll need to redirect the visitor to the default language. This can easily be done with meta tag refresh.

META tag syntax

The syntax of the refresh META tag is very simple.

<META http-equiv=”refresh” content=”<time>[;URL=<new url>"]>

  • The time, in seconds, represents the time that the browser will wait before refresh the page or redirect it to another one. If you set it to 0 (zero), the browser will redirect to the page without waiting. This use disable the back button of the browser, it behave like there is no initial page and only the one that we redirect the visitors to;
  • The url is an optional parameter. With this parameter we can define the URL of the page that will be loaded by the browser, this is the page that you want the visitor to redirect;

Examples

  1. Using the META tag to refresh or reload the site every one minute (60 seconds)
    <meta http-equiv=”refresh” content=”60″>
     
  2. Using the META tag to redirect to a new page without waiting.
    <meta http-equiv=”refresh” content=”0;url=en/index.html”>
     
  3.  Using the META tag to redirect to a new page after 2 minutes (120 seconds).
    <meta http-equiv=”refresh” content=”120;url=en/index.html”>

Things you must be aware

This META tag is an easy way of doing a refresh or a redirect. However, it has some disadvantages.

  • Using this method to redirect a page to another the crawlers, like Google bot, won’t keep your page rank in the new page. To do that you need to send a 301 redirect either with server script or the server configuration;
  • If the time defined in the META tag refresh is too small, some old browser with a slower connection can disable the browsers back button, even if you don’t define 0;
  • The use of the META tag refresh to reload or redirect a page should be done carefully in terms of usability. Some visitors may think that your site can be a security threat or simply be hungry about seeing the page reloads while he is reading it.

If you are developing a website according to the standard XHTML 1.0 you’ve to use the tag like following:

<META http-equiv=”refresh” content=”<time>[;URL=<new url>"] />

Last week i had to make backup’s of some websites through the Linux shell. I usually don’t have to make server administration and i don’t remember all the linux commands that I needed to do the job, then i decided to make this post for future task guide.
When I say backup a site, i mean [...]

Usually i use phpMyAdmin to configure, change and import/export my databases. However, recently, one of my databases went so big that it i have some problems to export or import it. The solutions is doing it with the Linux shell.

Linux shell can be very painful but can be the solution either. Using it to import or export MySQL databases can be a better and easier way. With shell we can backup all our databases and download only one file, or we can set up a cron job that do backup according to a defined schedule. Another major advantage is the possibility of import large SQL dump files (the phpMyAdmin has a limit).

Regular Expressions are a powerful and effective way to do searches and replaces in a String. With this feature we can do complex validations in only a few lines of code. However, when dealing with really complex expressions it can be harder to use, specially when we code in different languages, like PHP, JavaScript, ASP.Net, and other.

JavaScript allow us to use Regular Expressions in two different ways. We can do it with a literal expression, or with the RegEx Object. The major difference between this two ways is that with the Object we can change the expression at runtime. However, when we use literal regular expressions we achieve better results, because the literal expressions are compiled at load time and provides better performance.

Yesterday I was planing a CronScript to run every night and do some processing tasks. I was coding over Code Igniter (CI) and had my application structured to fit the MVC model.
CronScripts are usually small scripts that do some maintenance to the database, send e-mails, clean cache files, generate reports and other periodic tasks or [...]

In Web developing there are some main features and many concerns that we all must be aware. The file uploading is one of the important and indispensible features that we certainly will use sooner or later.
 
I’m sure that many of you have had troubles when uploading files that have names with special chars, especially if [...]

While searching and testing for good technical posts, here is another opinion one. Today I was searching for free software for convert MIDI to MP3. Yes, the old MIDI files because I want to have music in a website but I don’t want to violate copyrights. Then I found a website that has some free [...]

If you don't found what you need...Google It


Google
 

Recent comments

Valid XHTML 1.0 Transitional Valid CSS!

Recent posts

2007-2008 © ProTech, All rights reserved | Powered by WS4.org