There are 3 main types of redirects:
301 – moved permanently; recommended for SEO; indicates to both visitors and search engines that the page has moved permanently; the search engines will carry any link weighting from the original URL to the new page;
302 – moved temporarily; they are not treated as permanent changes, therefore these redirects wont pass the rankings and the search engine value like a 301 does; you should use it only if – for some reasons – you don’t want to transfer the link values from the old page to the new URL
meta refresh; these are redirects executed on page level rather than server level; not recommended for SEO
OK. Now, let’s see the most common methods that can help you to implement a URL redirection using various coding techniques or an .htaccess file.
- PHP redirect
- Java (JSP) redirect
- .htaccess redirect
First of all, let’s clarify what is an .htaccess file! Is the short form for “Hypertext Access” and it’s a web server configuration file used by Apache-based web servers in order to indicate who can or cannot access the contents of a given file directory. It was introduced mainly as a directory-level user authentication method, but over time has become a powerful configuration tool that can be used for many purposes.
This tutorial is not about .htaccess, so I won’t go into details, but you should know, that even the slightest syntax error can have disastrous consequences, so if you are not 101 percent sure about what are you doing, probably isn’t a very good idea playing around with your .htaccess file! And before doing anything else, always read the specific instructions provided by your hosting company! Also, keep in mind, that we are talking about a hidden system file (is hidden with a reason!), so make sure your FTP client is configured to show hidden files.
The .htaccess file can be created and/or edited as a regular TXT file, using a common text editor. It’s a good idea to name it “htaccess.txt” and rename it later – once has been uploaded to your root directory -, because many FTP applications or operating systems are unable to view or read .httaccess files.
Regards,
Nila