WordPress Redirect Method

Wordpress Redirect Method

There will be times where you would like to redirect visitors to another section of your site when they see a certain page or post. Reasons for this particular can be that you renamed its own URL and a post, a page was removed or you would like a different page.

The name ‘ redirect says it all: It sends visitors traveling to an alternate one to a particular page. However, what exactly does this 301 mean and how can it differ from a 302 redirect? Both send your users to a page that is different.

The sole subtle (yet quite significant) difference is the fact that a 301 will forever send visitors and search engines to the brand new destination. 302 redirects suggest that you just briefly need visitors to be sent to a page that is different.

This procedure is just available on Apache servers. Nginx needs extensive understanding of system management and has their particular way of defining redirects in the server settings.

These settings can get rather unmaintainable over time, particularly when you’re an enthusiastic blogger or you’re striving to enhance the Search Engine Optimization of your posts. In addition to that, edit the files, you’d need to log in on your own server over FTP and re-upload them every single time you add a redirect that is new. Why, generally, using this approach isn’t regarded as the strategy to use that’s.

As WordPress developer, you’ve got two choices:
wp_redirect function.

An example of PHP that is clear could be as follows:

// MyExampleFile.php
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.my-blog.com/a-new-destination"); 

And this is how you’d do the same, but now by using WordPress’ built-in function:

wp_redirect( "http://www.my-blog.com/a-new-destination", 301 );

If you forget to add the 301, both WordPress and PHP will both assume that it’s a 302 redirect, which isn’t always the case.

This method is a bit easier than editing files on the server, but can also become cumbersome once the amount of redirects increases.

Influencer Marketing increase your business sales <<<


About kevinban

Leave a Reply

Your email address will not be published. Required fields are marked *