Can’t get 301 redirect to work, what now? This solution was found after spending hours and days searching online.
I have tried numerous codes and plugins as well that I have not been satisfied with as you likely have.
If you can’t get 301 redirect to work for your site, pages or post that you want forwarded try one of the two solutions below.
The most common thing that people confuse when attempting to redirect a page is the difference between an HTML 301 redirect and a PHP 301 redirect.
Without getting to technical an HTML site will be considered a hand built site. A PHP website is built dynamically, a WordPress site for example.
To be able to redirect pages and post in either format, you need access to your .htaccess file on your server.
HTML 301 Redirect Code
Open your .htaccess file and paste the following code at the very top of the file, before any other coding in the file.
The first address is the original page. The second address is where you want to send people to when they try to visit the original page.
*Notice that there is a space between the two web addresses. You can add as many redirects as you need just put your new code right beneath the first code like the example below.
PHP 301 Redirect (WordPress)
If you have WordPress installed your .htaccess file will have code within it already. Paste the code below at the very top of the file.
The first address is the original page address. If your site is not in the root folder edit the first address. Example: blog/your-website-page-name-here/
The second address is where you want to send folks that try to visit the first website address. *Notice, the second website address ends with a ( / ) slash. If the new address ends with .html remove the slash and type .html at the end of the new address.
If you want to 301 redirect multiple pages, add another line to the code like the example below.
If you want to redirect the entire domain name, only use the code below.
Once you are finished editing your .htaccess file, save it and then upload it to the original site that you are going to be sending traffic from.
If your website gets a decent amount of traffic it should take search engines less than 30 days to recognize your 301 redirects.
You can delete the post or page once your new site shows up in search results for the title. You may however want to keep the old site live for an additional year or until you have contacted everyone with links to the site.
Test your 301 redirect by typing in the old page address. Once you hit enter, you should be directed to the new site without any lag time.
If you know anyone else who can’t get 301 redirect to work for them, please send them here or share this article.