What is redirect with example?

Redirect is the effective way to redirect users from one URL to another. For example if you forget your WordPress login ID or password, you can log in to your administration dashboard by using the forgot password link. Just enter your domain name and the following link will load: “yoursite.com/wp-admin/”. This link will automatically take you to the login page. Similarly you can redirect any URL to another. Let us see how much types of redirects available in WordPress.

Difference between 301 and 302 Redirects

Redirects are either HTTP status code 301 or 302. By default, every 301 redirects are permanent. On the other hand, 302 redirection is temporary and shows the 302 status code.There is also another type of 307 redirection which is temporary too. However, this is not widely used and you won’t see this type of links in your daily activity. If you are redirecting to your own domain, then 301 is the correct one to use. Otherwise, 302 is fine.

301 Redirect

301 redirect is a permanent way of redirecting users to new location. When a user visits a website, the server stores the header information of all the pages. Therefore, when a user logs off, the server knows which URL the user was browsing. When the user tries to visitthe same page, the web server reads the header information and loads the page again in the browser. This is how search engines like Google access your page. A 301 redirect is useful for websites to redirect old URLs to new pages. In this article, we will use 301 redirections. 301 redirects are preferred by Google for search engine rankings as compared to the 302 which is also used for SEO purpose. You can use a plugin or code snippet for301 headers in your WordPress website.

READ More:  How do you delete a Twitter account permanently?

Example of 301 Headers

Canonical and other top websites always use 301redirects for advanced SEO. Below is the view of 301 headers of a canonical page in Google Chrome browser. You can see that 301 is the HTTP status which tells the server that a page has moved to a new address. The 301h header contains the information about the 301 and where it is moving to. In this case, it is pointing to the root directory of the website “www.example.com”. Now you can replace the canonical tag from your website and test from different browsers. Thecorrect 301 header and code will have only one 301 in the response. If you still see multiple 301 entries in the response, then this is the 302 type of response.

301 Header with 2 301 Entries

How to 301 Headers in WordPress?

You can add a 301header code in “.htaccess” file of your domain. You can create this file by logging into your hosting account and navigating to “File Manager” section. Click the file tab and create a “.htaccess” file. The file will not show in file manager or cPanel until you click the “show hidden files” button. Additionally, you can use any FTP tool to create a .htaccess file. Then go to the root directory of your domain and search for “htaccess” file. Open and replace any existing 301redirection code with the new 301 codes below.

# BEGIN 301 REDIRECT /home/index.php http://yourwebsite.lol/home/ [R=301,L=1]# END 301 REDIRECT

The above code is for 301 permanent redirection of “http://yoursite.lol/home/” to “http://yourwebsite.lol/”. Make sure to change the domain name in the code only and leave the rest of thecode as it is. Save the file in “text” format and upload it back to the root directory using FTP.

READ More:  Why can't iMessage enable?

There are few other options for adding 301 or 302 rerouting in “.htaccess” file. If you are using “Cloudflare” CDN, then you can use 301 “Cloudflare” plugin for adding 301 301redirect to your WordPress website. In the plugin, you can define the type of 301 301, whether it is a temporary or permanent. The plugin will automatically add the required 301 301 to the “.htaccess” which helps in speeding up the loading of your site. The 301 301 from CloudFlare is a good option ifyour website is hosted on shared hosting. Many cloud hosting providers do not allow editing of “.htaccess” file. You can also use a WordPress plugin called “Simple 301 Redirect” to add 301 rerouting to your WordPress website.

301 Plugins in WordPress

302 Redirect

It is the latest version of 301 and includes the added functionality of temporary. This is mainly used for websites that are under construction. For example, if you are developing a website, you can set up a “coming soon” page which will show a dummy image or message. This can help inform people about the launch and also test theoperations on the site before you launch it to the public. Many large corporate or eCommerce sites use 302 for redirecting to landing pages. A/B testing with 301 or 302 redirects is also an effective method to test various web pages, check traffic and study user behavior. You can perform A/B tests for the landing pages and find out which one is more powerful. We will discussabout A/B tests in later articles. For now, try the above 301 and 302 redirections and make your WordPress blog or site rank well in search results. Thanks for reading this article and let us know your comments in the comment section below.

READ More:  How do you cook Brocolini?

Dannie Jarrod

Leave a Comment