How do I fix a 404 with a 301
-
I understand the need for fixing 404's but I have yet to have a serious walkthrough of how to set up a 301. From all the talk on the forums and such I'm pretty sure this is easy but I've just never done it before and I could really use a walk through.
Thanks
-
Hi Ben,
Did one of these responses answer your question for you? If not, also let us know if you're running anything like Wordpress or Drupal, and we can help give you more specific answers.
-
-
Hi Ben,
You probably want to redirect a single page if it is going to a 404. In which case you probably just want add code into the header of the problem page. Whilst you are at it, it might be worth checking that your non-www. pages are forwarding to the www versions. (http://exampledomain.com -> http://www.exampledomain.com)
PHP Redirect
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.exampledomain.com" );
?>Htaccess 301 Redirect (non-www. to www.)
Options +FollowSymLinks RewriteEngine On
RewriteBase / RewriteCond %{HTTP_HOST} !^www.exampledomain.com$ [NC] RewriteRule ^(.*)$ http://www.exampledomain.com/$1 [R=301,L]Custom 404 Page
I would also suggest a custom 404 page with links to your most popular pages, search and a back button.
Hope this helps.
C
-
I use .net when i build sites, iuse the Application_Error method to see if the error was a 404 tthen 301 to my home page. so any broken link 301 to my home page
-
404 error is rendered when the resource requested is not found. You can do 2 things:
- Implement 301 redirect to the new resource if it is related. The kind of redirect will depend upon the type of server your website is hosted on.
- If 301 redirect is not possible on all the pages (it's understandable), a custom 404 page is a worthy option. It will avoid unnecessary loss of visitors from your site as they tend to get pissed with the default 404 page. It will not only help you retain the visitors but also redirect them to the important pages of your website. E.g.Custom 404 Page
Hope it helps.
Regards
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
How to fix duplicate content for homepage and index.html
Hello, I know this probably gets asked quite a lot but I haven't found a recent post about this in 2018 on Moz Q&A, so I thought I would check in and see what the best route/solution for this issue might be. I'm always really worried about making any (potentially bad/wrong) changes to the site, as it's my livelihood, so I'm hoping someone can point me in the right direction. Moz, SEMRush and several other SEO tools are all reporting that I have duplicate content for my homepage and index.html (same identical page). According to Moz, my homepage (without index.html) has PA 29 and index.html has PA 15. They are both showing Status 200. I read that you can either do a 301 redirect or add rel=canonical I currently have a 301 setup for my http to https page and don't have any rel=canonical added to the site/page. What is the best and safest way to get rid of duplicate content and merge the my non index and index.html homepages together these days? I read that both 301 and canonical pass on link juice but I don't know what the best route for me is given what I said above. Thank you for reading, any input is greatly appreciated!
On-Page Optimization | | dreservices0 -
404's Wordpress products
Hi Guy's, On a Wordpress website we have a SEO Ultimate plugin running. Every day i get lot's of 404 errors of products that doesn't exist anymore (but are indexed, site: .... ). In the beginning we had lot's of testproduct that are not coming back in the shop. So i was wondering if there is a way to automaticly redirect product when there are out of stock, or not comming back anymore... So my 404's can be fixed. Thanks!
On-Page Optimization | | Happy-SEO1 -
With 301 Redirects Does Changing URLs Matter?
We are redesigning our website in order to give it a more modern visual look. For the most part all the content will remain the same. Our old site is hosted on .asp so all of our current URLs look something like this: www.example.com/products/food.asp We plan on using 301 redirects in order to update every URL and remove the .asp. Since we are going to be doing 301 redirects for every existing URL anyways, does it matter from an SEO and ranking standpoint, if we also change the content and structure of the URL? For example, would we see a ranking impact if we were to change the above example URL to www.example.com/food? Obviously we want to try to retain as much link juice and ranking factors as possible during this redesign. Another issue we are seeing is with the image file names of our existing website images. We are moving to a new CMS platform (WordPress) that automatically saves images using a folder path similar to this: wp-uploads/2015-08/food. Will that change affect our SEO or ranking at all? When Google crawls an image does it care about the full path? Any insight would be much appreciated! 🙂
On-Page Optimization | | BlueLinkERP0 -
Duplicate Content aka 301 redirect from .com to .com/index.html
Moz reports are telling me that I have duplicate content on the home page because .com and .com/index.html are being seen as two pages. I have implemented 301 redirect using various codes I found online, but nothing seems to work. Currently I'm using this code. RewriteEngine On
On-Page Optimization | | omakad
RewriteBase /
RewriteCond %{HTTP_HOST} ^jacksonvilleacservice.com
RewriteRule ^index.html$ http://www.jacksonvilleacservice.com/ [L,R=301] Nothing is changing. What am I doing wrong? I have given it several weeks but report stays the same. Also according to webmasters tools they can't see this as duplicate content. What am I doing wrong?0 -
Boatload of 301 Redirects Question
We have a client that came to us and they recently did a site makeover. Previously they had all their pages in root directory including 75+ spammy article pages. On their makeover, they moved all the article pages into a directory and added 301 redirects. In going over their site we noticed they have redundant articles, like an article on blue-marble-article.htm and blue-marbles-article.htm Playing on singular and plural with dulpicate content for most part with exception to making it plural. If they have 75 articles, Id say 1/3 are actually somewhat original content. I would like to 301 redirect 2/3's of the articles to better re-written article pages but that would add a whole lot more 301 redirects. We would then have a 301 redirect from root directory to article directory, then another 301 redirect from spam article to new re-written article. My question is, would this be too many redirects for googlebot to sort through and would it be too confusing or send bad signals? Or should I create a new directory with all good articles and just redirect the entire old articles directory to the new one? Or just delete the redirects and old spammy directory and let those fall on a 404 error page. Id hate to lose 50-75 pages but I think its in fact those spammy pages that could be why the site fell from top of first page google to third page and now 10th page in a years time. I know, Im confused just typing this out. Hope it makes sense for some good feedback and advise. Thanks.
On-Page Optimization | | anthonytjm0 -
Site wide 301 or canonical links.
Hi guys, I'd like add code to my header file to specify www. as opposed to just http:// for the canonical links across my entire site. How can I do this? I'd like it to be site wide code that I can just add to my header.php file which is included across the site.
On-Page Optimization | | absoauto0 -
My website is saying I have duplicate page content and page title. How do I fix it?
Hi, I created a website on webstarts.com. After I launched it then ran a scan through SEO it says I have duplicate page content and page title. The 2 pages it is reading are technically the same page. www.mobilemowermedicsinc.com and www.mobilemowermedicsinc.com/index . I am unsure how to get rid of on of these as it keeps saying this is an error in the SEO scan. Could someone please advise me of what to do from here. Thanks!
On-Page Optimization | | bcarp880 -
301 redirects / clean urls
hello everyone, we moved our site to a new platform that has url rewrite feature. we are building out a spreadsheet of the old aspx urls and the corresponding page on the new site. my dev tells me that its not important to redirect the old page to the new "clean url" page which sounds a bit odd to me ..example below. okay. so he says its the same difference to 301 redirect this url: http://72.3.181.97/catalog/DesignerDogBeds.aspx to this urls: https://www.k9electronics.com/product.php?productid=3474 instead of this clean url: http://www.k9electronics.com/designer-dog-beds/ can anyone give me any feedback on this? thanks!
On-Page Optimization | | k9byron0