500 Error Using TraversyMVC on Shared Hosting

For the TL;DR, click here.

Brad Traversy‘s got a great course on building a custom MVC (model-view-controller) framework in PHP. It’s one of the best ways to learn the basics of building an MVC app.

I stumbled across a rather unique use case that had me Googling at all hours of the night to figure out. At first, I thought it was a bug in his code (alas, me of little faith!), until I applied some basic troubleshooting.

The application, which was deployed to battlestardigital.com at the time of this writing (a site has since replaced that app), worked perfectly on my localhost. However, when deployed to Production, it generated a 500 error.

After plenty of Googling, I crossed my fingers and contacted HostGator. After all, most of my sites sit on the same shared hosting account with those glorious nerds.

2+ hours of Support inquiries later, what was their solution?

Comment out the .htaccess.

“Look, it works now!”

Not so much.

Fortunately, one of the techs did provide a clue from his logs, which aren’t accessible to shared-hosting customers. The error hesaw was as follows:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary.

I ultimately solved the problem by moving this particular site from HostGator’s shared hosting plan over to AWS.

My theory, which is hard to confirm without direct access to the Linux server behind my HostGator account, is that they rely on redirects to handle multiple sites on the same account.

A quick look at the zone file shows the following:

When I signed up for HostGator waaaaaaaaaaaaaaaaayy back in the day, my vision was to run a site dedicated to fitness for fathers. 14 O’Clock was a reference to how my two-year-old reported the time.

Four years and buckets of chicken wings later, that site is a pipe dream.

But, I digress.

Because 14oclockfit.com was my original domain name, all additional sites created under my shared hosting plan are actually subdomains of 14oclockfit.com.

But, you don’t have to type battlestardigital.14oclockfit.com to get to my site. Instead, when I registered the domain and selected “add-on domain” in cPanel, I believe HostGator set up a redirect so that visitors to battlestardigital.com would see my site without having to type in the full URL.

And, because the TraversyMVC framework relies on redirects, I crossed the magic threshold of 10.

TL;DR

Moving battlestardigital.com from my shared hosting plan to a dedicated Amazon EC2 instance solved the problem for me.

If your TraversyMVC project works fine locally but gives you the finger on a shared hosting account, try moving it to dedicated hosting. If that works, awesome, let me know! If not, hit me up the comments and we’ll see if we can’t solve it together.

Cheers!

5 1 vote
Article Rating
Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Abdullah
Abdullah
2 days ago

hello Paul i am facing same problem then what should i do??

1
0
Would love your thoughts, please comment.x
()
x