undefined
Skip to content
Moz logo Menu open Menu close
  • Products
    • Moz Pro
    • Moz Pro Home
    • Moz Local
    • Moz Local Home
    • STAT
    • Moz API
    • Moz API Home
    • Compare SEO Products
    • Moz Data
  • Free SEO Tools
    • Domain Analysis
    • Keyword Explorer
    • Link Explorer
    • Competitive Research
    • MozBar
    • More Free SEO Tools
  • Learn SEO
    • Beginner's Guide to SEO
    • SEO Learning Center
    • Moz Academy
    • SEO Q&A
    • Webinars, Whitepapers, & Guides
  • Blog
  • Why Moz
    • Agency Solutions
    • Enterprise Solutions
    • Small Business Solutions
    • Case Studies
    • The Moz Story
    • New Releases
  • Log in
  • Log out
  • Products
    • Moz Pro

      Your all-in-one suite of SEO essentials.

    • Moz Local

      Raise your local SEO visibility with complete local SEO management.

    • STAT

      SERP tracking and analytics for enterprise SEO experts.

    • Moz API

      Power your SEO with our index of over 44 trillion links.

    • Compare SEO Products

      See which Moz SEO solution best meets your business needs.

    • Moz Data

      Power your SEO strategy & AI models with custom data solutions.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    Learn more
  • Free SEO Tools
    • Domain Analysis

      Get top competitive SEO metrics like DA, top pages and more.

    • Keyword Explorer

      Find traffic-driving keywords with our 1.25 billion+ keyword index.

    • Link Explorer

      Explore over 40 trillion links for powerful backlink data.

    • Competitive Research

      Uncover valuable insights on your organic search competitors.

    • MozBar

      See top SEO metrics for free as you browse the web.

    • More Free SEO Tools

      Explore all the free SEO tools Moz has to offer.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    Learn more
  • Learn SEO
    • Beginner's Guide to SEO

      The #1 most popular introduction to SEO, trusted by millions.

    • SEO Learning Center

      Broaden your knowledge with SEO resources for all skill levels.

    • On-Demand Webinars

      Learn modern SEO best practices from industry experts.

    • How-To Guides

      Step-by-step guides to search success from the authority on SEO.

    • Moz Academy

      Upskill and get certified with on-demand courses & certifications.

    • MozCon

      Save on Early Bird tickets and join us in London or New York City

    Unlock flexible pricing & new endpoints
    Moz API

    Unlock flexible pricing & new endpoints

    Find your plan
  • Blog
  • Why Moz
    • Small Business Solutions

      Uncover insights to make smarter marketing decisions in less time.

    • Agency Solutions

      Earn & keep valuable clients with unparalleled data & insights.

    • Enterprise Solutions

      Gain a competitive edge in the ever-changing world of search.

    • The Moz Story

      Moz was the first & remains the most trusted SEO company.

    • Case Studies

      Explore how Moz drives ROI with a proven track record of success.

    • New Releases

      Get the scoop on the latest and greatest from Moz.

    Surface actionable competitive intel
    New Feature

    Surface actionable competitive intel

    Learn More
  • Log in
    • Moz Pro
    • Moz Local
    • Moz Local Dashboard
    • Moz API
    • Moz API Dashboard
    • Moz Academy
  • Avatar
    • Moz Home
    • Notifications
    • Account & Billing
    • Manage Users
    • Community Profile
    • My Q&A
    • My Videos
    • Log Out

The Moz Q&A Forum

  • Forum
  • Questions
  • Users
  • Ask the Community

Welcome to the Q&A Forum

Browse the forum for helpful insights and fresh discussions about all things SEO.

  1. Home
  2. SEO Tactics
  3. Intermediate & Advanced SEO
  4. Can an incorrect 301 redirect or .htaccess code cause 500 errors?

Moz Q&A is closed.

After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

Can an incorrect 301 redirect or .htaccess code cause 500 errors?

Intermediate & Advanced SEO
4
10
4.0k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as question
Log in to reply
This topic has been deleted. Only users with question management privileges can see it.
  • kimmiedawn
    kimmiedawn last edited by Mar 10, 2014, 3:54 PM

    Google Webmaster Tools is showing the following message:

    _Googlebot couldn't access the contents of this URL because the server had an internal error when trying to process the request. These errors tend to be with the server itself, not with the request.  _

    Before I contact the person who manages the server and hosting (essentially asking if the error is on his end) is there a chance I could have created an issue with an incorrect 301 redirect or other code added to .htaccess incorrectly?

    Here is the 301 redirect code I am using in .htaccess:

    RewriteEngine On

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/.]+/)*(index.html|default.asp)\ HTTP/

    RewriteRule ^(([^/.]+/)*)(index|default) http://www.example.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} !^(www.example.com)?$ [NC]

    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    Could adding the following code after that in the .htaccess potentially cause any issues?

    BEGIN EXPIRES

    <ifmodule mod_expires.c="">ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-icon "access plus 1 year"</ifmodule>

    END EXPIRES

    (Edit) I'd like to add that there is a Wordpress blog on the site too at www.example.com/blog with the following code in it's .htaccess:

    BEGIN WordPress

    <ifmodule mod_rewrite.c="">RewriteEngine On
    RewriteBase /blog/
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]</ifmodule>

    END WordPress

    Thanks

    1 Reply Last reply Reply Quote 0
    • ThompsonPaul
      ThompsonPaul @kimmiedawn last edited by Mar 31, 2014, 3:00 AM Mar 31, 2014, 3:00 AM

      Just to follow up on your last question about 404s, Kim...

      No, having a bunch of 404s like that will be no more work for the server than if they were landing on actual blog pages - in fact somewhat less work as the 404 page generally has less content and far fewer database calls.

      Also, a page timing out due to server load (server working too hard) doesn't generally result in a 500 error, it just returns a timed-out error. 500 errors are delivered when something actually breaks the server's ability to deliver the correct page content.

      Paul

      1 Reply Last reply Reply Quote 0
      • topic:timeago_earlier,20 days
      • kimmiedawn
        kimmiedawn last edited by Mar 10, 2014, 7:40 PM Mar 10, 2014, 7:40 PM

        Wow, you are very quickly and easily making me much better at what I do:) Thanks for that.

        I actually just updated the code a couple days ago by adding the Expires code and fixing the redirect. Maybe the previous double 301 redirect could be the culprit? Or - something I mentioned in another question - there were a ton of 404s because of a blog that wasn't redirected to the /blog subdirectory correctly, which I fixed recently. Could something like that cause the server to work to hard and return a 500 server error?

        I'll definitely check out the logs and Pingdom.

        Great information and advice.

        ThompsonPaul 1 Reply Last reply Mar 31, 2014, 3:00 AM Reply Quote 1
        • ThompsonPaul
          ThompsonPaul @ThompsonPaul last edited by Mar 10, 2014, 7:37 PM Mar 10, 2014, 7:37 PM

          Sorry - and to be clear about your htaccess testing question - no there's no "tool" I've ever heard of. You test it by doing exactly as you've done - ensuring that pages respond correctly and with correct headers. Then you implement a monitoring system to ensure that you know every time that correct behaviour fails. That way you can get the site back up quickly, and have a record of when & how often it happened so you can properly troubleshoot if you have an issue.

          Three troubleshooting steps

          1. become aware as soon as there is a problem
          2. fix the problem asap to minimize impact on users
          3. investigate and fix the root cause so it doesn't happen again.

          All of these steps depend on a monitoring/alerting system, otherwise you'll always be behind the curve and/or working in the dark.

          Hope that helps?

          Paul

          1 Reply Last reply Reply Quote 0
          • RobertFisher
            RobertFisher @ThompsonPaul last edited by Mar 10, 2014, 7:33 PM Mar 10, 2014, 7:33 PM

            Great answer Paul.

            1 Reply Last reply Reply Quote 0
            • ThompsonPaul
              ThompsonPaul @kimmiedawn last edited by Mar 10, 2014, 7:38 PM Mar 10, 2014, 7:28 PM

              As far as I understand, Kimberly, you've only changed the htaccess in the last day or 2? in which case the server error would have been from before your updates.

              As far as monitoring - you can check the server error logs (via FTP or in cPanel if that's what the hosting account uses) to check for frequent 500-level server errors.

              In addition, I strongly recommend that all commercial sites must have uptime monitoring in place. I like to use Pingdom's paid basic plan which allows monitoring of up to 10 pages. I then select a number of relevant pages and set the tool to test each page, and to check for an actual text snippet on each page (using their custom settings). I monitor things like the home page, the blog home page, a blog post, a blog category page, and critical call-to-action pages. Basically different types of page templates that might respond differently to server issues. plus critical money-making pages.

              This way, Pingdom will alert you immediately any time those pages don't respond normally (like when a server gives back a 500 error, or the server goes unresponsive due to overload etc). Monitoring these pages every minute is the ONLY way to really know whether your server and website software are performing properly and consistently. This is a critical component of any professionally run website, in my opinion.

              Often Pingdom confirms that things are running fine, but I literally can't count the number of times I've instituting uptime monitoring for new clients, only to find the site has huge downtime no one was really aware of, because they just aren't on their own site often enough to know when it's down. (And you certainly shouldn't be relying on customers to inform you the site has issues. By then it's FAR too late.)

              Paul

              P.S There are certainly other uptime monitoring systems out there, some are even free. I recommend Pingdom because I've used it for years and it's been consistently excellent. Also, it allows for per-minute checks instead of every 5 minutes, and can check for actual page content, not just server response. In addition, when it finds an outage, it runs a root cause analysis. So it would actually tell you that a 500 error caused the check failure (as opposed to server timing out, which is a different problem). No other affiliation.

              ThompsonPaul 1 Reply Last reply Mar 10, 2014, 7:37 PM Reply Quote 0
              • kimmiedawn
                kimmiedawn last edited by Mar 10, 2014, 7:06 PM Mar 10, 2014, 7:06 PM

                Paul - Thanks for a new way to check and understand all this.

                So, if I was able to visit the page just fine normally, and after setting the user agent to Googlebot, then I should be good? I never saw a 500 server error while visiting the page, just in Webmaster Tools. It was dated 2 days ago, but there have been other server error warnings over the past month or two in GWT, so maybe it is a resolved issue.

                Can you suggest a method to confirm the overall proper functioning of the .htaccess code? Is there a tool you use to validate your .htaccess code? I checked response headers in Firebug and found all 200 OKs and 304s for images (from the expires header I assume) so to my amateur viewpoint, it looks good. I just don't want to tank the site unwittingly. Obviously not.

                ThompsonPaul 1 Reply Last reply Mar 10, 2014, 7:28 PM Reply Quote 0
                • ThompsonPaul
                  ThompsonPaul last edited by Mar 10, 2014, 6:38 PM Mar 10, 2014, 5:59 PM

                  To note, Kimberly - Webmaster tools keeps a historical record of issues. It may be showing you server error that occurred in the past, but is no longer a problem. Easiest way is to test the URL it is reporting as having problems.

                  First test by visiting the URL using a regular browser. Then revisit using a regular browser, but with the user-agent set to imitate the Googlebot crawler since it's Googlebot that's reporting the error. (You can do this using the Set User Agent tool built into the Moz Firefox toolbar, or others. It's a critical capability to have for many purposes.) It's possible for the Googlebot to have issues even if a regular visitor sees none, so you want to test for both.

                  Assuming these tests return the 500 server error, just briefly rename the pertinent htaccess file for a minute, then go back and rerun the tests. If the error goes away with the htaccess disabled, you know the source of the problem lies in the htaccess rules. If the problem persists, you can be pretty certain it's not the htaccess causing it.

                  Make sense?

                  Paul

                  RobertFisher 1 Reply Last reply Mar 10, 2014, 7:33 PM Reply Quote 2
                  • RobertFisher
                    RobertFisher last edited by Mar 10, 2014, 5:38 PM Mar 10, 2014, 5:38 PM

                    Kimberly,

                    It can, but without which 5XX it is, it is harder to diagnose. (Is it an endless loop, or something else)

                    I would suggest (based on you trying to redirect what appears to be homepage whether or not the request is for asp or html) this help from Apache.  It is a bit deep, but you appear to want to do it yourself and this is a resource I would suggest.

                    If you look about a third down the page there is a content box that covers tons of variables.

                    Best,

                    1 Reply Last reply Reply Quote 1
                    • Andy.Drinkwater
                      Andy.Drinkwater last edited by Mar 10, 2014, 5:24 PM Mar 10, 2014, 5:24 PM

                      Hi Kimberly,

                      Yes, an incorrect 301 or bad code can cause a 500 internal error. Unfortunately, I am not too hot with writing re-write code, so can't tell you if everything you have there is perfect. That said, you might find some help here and here.

                      -Andy

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 out of 10
                      • First post
                        1/10
                        Last post

                      Got a burning SEO question?

                      Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                      Start my free trial


                      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.

                      • See all categories

                      Related Questions

                      • Caffeine_Marketing

                        We are redirecting http and non www versions of our website. Should all versions http (non www version and www version) and https (non www version) should just have 1 redirect to the https www version?

                        We are redirecting http and non www versions of our website. Should all versions http (non www version and www version) and https (non www version) should just have 1 redirect to the https www version? Thant way all forms of the website are pointing to one version?

                        Intermediate & Advanced SEO | Dec 9, 2019, 6:00 PM | Caffeine_Marketing
                        0
                      • viatrading1

                        Several 301 Redirects to Same Page

                        Hi, I have 3 Pages we won't use anymore in our website. Let's call them url A, url B and url C. To keep their SEO strength on our domain, I've though about redirecting all of them to url D. For what I understand, when 301 redirecting, about 85-90% of the link SEO juice is passed. Then, if I redirect 3 URLs to the same page... does url D receive all the link SEO juices for URLs added up? (approximately)
                        e.g. future url D juice = 100% current url D juice + 85% url A juice + 85% url B juice + 85% url C juice Is this the best practice, or is there a better way? Cheers,

                        Intermediate & Advanced SEO | Oct 14, 2015, 12:28 AM | viatrading1
                        0
                      • Angelos_Savvaidis

                        Multilingual Site and 301 redirection

                        Hey there awesome people of Moz I have this site that has many languages in it. The main language is English and my developer did the following www.example.com ( is the main site ) which redirects with a 301 to www.example.com/en if your geo location is supported by our languages then you will automatically be redirected to whatever language you have in your country but does the first language with is english have to 301 redirect to www.example.com/en ? I thought that the right way is to just leave /en at the root file. Thanks in advance

                        Intermediate & Advanced SEO | Apr 2, 2015, 12:15 AM | Angelos_Savvaidis
                        0
                      • IanOBrien

                        Changing URL structure of date-structured blog with 301 redirects

                        Howdy Moz, We've recently bought a new domain and we're looking to change over to it. We're also wanting to change our permalink structure. Right now, it's a WordPress site that uses the post date in the URL. As an example: http://blog.mydomain.com/2015/01/09/my-blog-post/ We'd like to use mod_rewrite to change this using regular expressions, to: http://newdomain.com/blog/my-blog-post/ Would this be an appropriate solution? RedirectMatch 301 /./././(.) /blog/$1

                        Intermediate & Advanced SEO | Feb 3, 2015, 12:52 PM | IanOBrien
                        0
                      • RosemaryB

                        Should we 301 redirect old events pages on a website?

                        We have a client that has an events category section that is filled to the brim with past events webpages.  Another issue is that these old events webpages all contain duplicate meta description tags, so we are concerned that Google might be penalizing our client's website for this issue.   Our client does not want to create specialized meta description tags for these old events pages. Would it be a good idea to 301 redirect these old events landing pages to the main events category page to pass off link equity & remove the duplicate meta description tag issue?   This seems drastic (we even noticed that searchmarketingexpo.com is keeping their old events pages).  However it seems like these old events webpages offer little value to our website visitors. Any feedback would be much appreciated.

                        Intermediate & Advanced SEO | Nov 12, 2014, 3:08 PM | RosemaryB
                        0
                      • jasondexter

                        Multiple 301 redirects for a HTTPS URL. Good or bad?

                        I'm working on an ecommerce website that has a few snags and issues with it's coding. They're using https, and when you access the website through domain.com, theres a 301 redirect to http://www.domain.com and then this, in turn, redirected to https://www.domain.com. Would this have a deterimental effect or is that considered the best way to do it. Have the website redirect to http and then all http access is redirected to the https URL? Thanks

                        Intermediate & Advanced SEO | Apr 29, 2014, 5:09 AM | jasondexter
                        0
                      • BeytzNet

                        How to 301 redirect old wordpress category?

                        Hi All, In order to avoid duplication errors we've decided to redirect old categories (merge some categories).
                        In the past we have been very generous with the number of categories we assigned each post. One category needs to be redirected back to blog home (removed completely) while a couple others should be merged. Afterwords we will re-categorize some of the old posts. What is the proper way to do so?
                        We are not technical, Is there a plugin that can assist? Thanks

                        Intermediate & Advanced SEO | Jun 10, 2013, 9:45 AM | BeytzNet
                        0
                      • SDLOnlineChannel

                        Is it ok to use both 301 redirect and rel="canonical' at the same time?

                        Hi everyone, I'm sorry if this has been asked before. I just wasn't able to find a response in previous questions. To fix the problems in our website regarding duplication I have the possibility to set up 301's and, at the same time, modify our CMS so that it automatically sets a rel="canonical" tag for every page that is generated. Would it be a problem to have both methods set up? Is it a problem to have a on a page that is redirecting to another one? Is it advisable to have a rel="canonical" tag on every single page? Thanks for reading!

                        Intermediate & Advanced SEO | May 25, 2012, 12:18 PM | SDLOnlineChannel
                        0

                      Get started with Moz Pro!

                      Unlock the power of advanced SEO tools and data-driven insights.

                      Start my free trial
                      Products
                      • Moz Pro
                      • Moz Local
                      • Moz API
                      • Moz Data
                      • STAT
                      • Product Updates
                      Moz Solutions
                      • SMB Solutions
                      • Agency Solutions
                      • Enterprise Solutions
                      Free SEO Tools
                      • Domain Authority Checker
                      • Link Explorer
                      • Keyword Explorer
                      • Competitive Research
                      • Brand Authority Checker
                      • Local Citation Checker
                      • MozBar Extension
                      • MozCast
                      Resources
                      • Blog
                      • SEO Learning Center
                      • Help Hub
                      • Beginner's Guide to SEO
                      • How-to Guides
                      • Moz Academy
                      • API Docs
                      About Moz
                      • About
                      • Team
                      • Careers
                      • Contact
                      Why Moz
                      • Case Studies
                      • Testimonials
                      Get Involved
                      • Become an Affiliate
                      • MozCon
                      • Webinars
                      • Practical Marketer Series
                      • MozPod
                      Connect with us

                      Contact the Help team

                      Join our newsletter
                      Moz logo
                      © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                      • Accessibility
                      • Terms of Use
                      • Privacy

                      Looks like your connection to Moz was lost, please wait while we try to reconnect.