There will be times when you will have to change your website address or move an old content to another section on your site (i.e. from blog post to resources). However, that does not mean that you need to re-build your site traffic and link authority from the ground up.
That’s because there is this thing called URL Redirection or URL Forwarding.
Good thing, you can simply install a plugin to implement a 301 redirect for WordPress sites. Meanwhile, there are different ways on how you can implement URL redirection on your website:
Ways to Redirect Your Webpage
You may have noticed that when you visit some websites, they will change their URL midway through the loading process. This is where URL forwarding occurs.
So, how do websites do it? Keep on reading to find out:
1. HTML redirects
HTML redirect is perhaps the simplest way to do a URL redirection. Moreover, it is a client-side redirection, wherein the redirect tag tells the browser to request a new page.
All you need to do is place a Meta Refresh tag within the <head> at the top of any HTML page. Your code should look something like this:
<meta http-equiv=”refresh” content=”0; URL=’https://newcompanywebsite.com’”/>
The “content” attribute determines the time of delay before the browser redirects the user to a new domain. So, in this case, it is set to 0 seconds.
Although this is the simplest way to implement a URL forwarding, it comes with a few hiccups.
- Some browsers freak out whenever it loads a web page with a Meta Refresh tag.
- Site visitors might see a flash as the old page loads before being redirected to the new one.
- HTML redirects disable the Back button on old browsers.
No wonder a lot of web developers discourage to use HTML redirects as a solution.
In fact, all you need is to change the “location” property on the “window” object:
window.location = “https://newcompanywebsite.com”;
There are also other ways to do it:
window.location.href = “https://newcompanywebsite.com”;
Aside from that, you can also do a couple of neat stuff with the “location” object. This includes reloading the page and changing the origin and path of a URL.
However, it comes with some caveats:
- You cannot relay redirect information since it does not have a status code.
- It is not clear how search engines react to this.
That said, you will need a server-side solution that can help with sending 301 responses to search engine bots and internet browsers.
3. Apache redirects
Apache redirect is the most common way of URL redirection. What you need to do is add a specific rule to a .htaccess on your Apache web server. And then let the web server do the heavy lifting for you.
In case you are unaware, a .htaccess is a document that allows you to give commands to Apache. On the other hand, Apache is a software that runs on your server.
Thus, you can create a new .htaccess file or edit an existing one in order to implement URL redirection. The URL forwarding rule that you will add should be like this:
Redirect 301 / https://newcompanywebsite.com
After that, you will add the file to the root directory of your old website. That way, a site visitor that will land on any page on your old website will be redirected to the new one.
However, the mentioned rule will only work on Linux servers, provided that the “mod_rewrite” is enabled. It is a module that allows you to redirect requested URLs on the server.
Most hosting companies have the “mod_rewrite” module enabled. Otherwise, you can contact your web host provider for more information.
4. Nginx redirects
If you are on an Nginx server, you can handle URL redirects by adding a server block in the nginx.conf file.
It is something like this:
return 301 $scheme://newcompanywebsite.com$request_uri;
There are a handful of best practices regarding Nginx. So, it is always a good idea to review and take a closer look at it before you tweak anything.
5. PHP redirects
A PHP redirect is quite straightforward, as you can set the URL redirect rule on the header function. However, this tactic comes with two issues:
- You need to set the rule before any markup or content
- The function sends a 302 redirect by default
What you need to achieve is a 301 permanent redirect. Thus, the PHP redirect rule should be:
header(‘Location: https://newcompanywebsite.com’, true, 301);
Adding the “true” parameter will help you replace the response code to 301.
There are various reasons you will need to implement a URL redirection on your website. Not to mention that there are basic ways to do that, including the use of a URL shortener.
This is not just to redirect your site visitors to the right page, but doing so can also help maximize your domain authority. The same thing goes if you want to maintain your search authority and link equity.
Do you know other tricks to redirect an old URL to a new one? Let us know in the comments!