Fallback for failed .htaccess?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Fallback for failed .htaccess?

Post by allspiritseve »

One of my client's sites is hosted at GoDaddy (their choice, not ours). GoDaddy's mysql server was rejecting all connections, and the site was down for almost 2 hours. I put up a friendly error message, but disabled the .htaccess file so that it wouldn't try to route traffic to the bootstrap file. After they fixed the problem, I enabled the site, and the .htaccess file... and then remembered that GoDaddy's server caches the .htaccess file. I had to wait another hour, hour and a half before it actually recognized the correct version.

This was one of the first sites we used clean urls with, and we have since coded a URL generator that will spit out clean urls if the bootstrap is loaded, and standard urls if not. This seems to be working fine, but is really a pain for sites that have more complex urls. I'd like to make clean urls standard at some point, but that means, for clients who prefer external servers such as GoDaddy, our hands are tied if something happens to the .htaccess file like it did today.

I'm wondering if anyone has any suggestions for how to avoid this. If our whole site has hard-coded urls such as /page1/page2/page3/, and the .htaccess doesn't work, then these urls are going to trigger a 404 error. I suppose we could hijack the error handler, but that would be bad for SEO, because every page would be seen as a 404 error page by search engines. Anyone have any better ideas?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Fallback for failed .htaccess?

Post by josh »

allspiritseve wrote: Anyone have any better ideas?
Give Karl ZImmerman a call @ steadfastnetworks
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Fallback for failed .htaccess?

Post by allspiritseve »

josh wrote:
allspiritseve wrote: Anyone have any better ideas?
Give Karl Zimmerman a call @ steadfastnetworks
Uh... who's that?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Fallback for failed .htaccess?

Post by omniuni »

Generate your links, instead of hard-coding them. Try a file_get_contents from someplace using a clean link, and if it works, return everything in clean format, else, return the links in regular ?page=blah kind of format.

Possibly more trouble than it's worth.... (just get a host that doesn't cache .htaccess! Gah, I hate GoDaddy. Dealt with this myself just the other night!)
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Fallback for failed .htaccess?

Post by allspiritseve »

I'd rather not generate the links unless I have to. Most of our clients' sites run off our own server, this is just for the select few who go against our recommendations and use a different host.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Fallback for failed .htaccess?

Post by Benjamin »

allspiritseve wrote:I'd rather not generate the links unless I have to. Most of our clients' sites run off our own server, this is just for the select few who go against our recommendations and use a different host.
If the client wants to use their own hosting provider, then I wouldn't support the site. If the environment is out of your control it's their problem.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Fallback for failed .htaccess?

Post by omniuni »

Unfortunately, I have to agree with Astions. There is a point where you have to cut your losses and say, "We can not keep dealing with this host. If you want us to continue development, you will need to do it on our own server, like all of our other clients."

They hire you for a reason. If otherwise they are happy with your services, they should trust you enough to follow your suggestion.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Fallback for failed .htaccess?

Post by Benjamin »

Yeah. On the other hand if you are billing them hourly to fix problems caused by their host I guess you aren't doing too badly.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Fallback for failed .htaccess?

Post by josh »

allspiritseve wrote:Uh... who's that?
The owner of the company. He helped me on Xmas eve in thru the a.m. when my old company tanked. He's the cheapest on the net and offers shared / VPS all the way up to dedis and colo. There's no 3rd party bullcrap scripts that obstruct you on his servers.
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Fallback for failed .htaccess?

Post by allspiritseve »

josh wrote:
allspiritseve wrote:Uh... who's that?
The owner of the company. He helped me on Xmas eve in thru the a.m. when my old company tanked. He's the cheapest on the net and offers shared / VPS all the way up to dedis and colo. There's no 3rd party bullcrap scripts that obstruct you on his servers.
Ah... thanks for the recommendation, but we have our own server. This is just for the rogue client who thinks they're getting a better deal by hosting at GoDaddy or whatever. We've had so many problems with .htaccess that I'd love to have a way to easily switch our codebase to emulate clean urls without .htaccess. That way, we don't have problems later on (like it or not, some clients want a cheap host, and we just can't afford to leave them completely in the dust.)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Fallback for failed .htaccess?

Post by Benjamin »

Here's how I look at it. Even if you have only spent 20 hours over the course of the last 12 months fixing issues on their site because of the server, assuming you charge $45 per hour, the added cost of the "cheap" hosting is now $900 + whatever they already pay.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Fallback for failed .htaccess?

Post by omniuni »

Astions, sometimes you just can't convince a client of things like that. They'd rather pay you double, than pay the host. :|
Post Reply