phone number

A creative, friendly web design company based in Chelmsford, Essex

back light

Host Server Updates Changing htaccess File

You may be aware that I wrote a while back about how Free Virtual Servers were affecting my .htaccess file with their own server changes – it seems that your code can be messed with without your permission or prior warning or notification. We use Mobile Detect to redirect our desktop site to a mobile version depending on what the user is using to view our site. To do this we need to parse our html site as php. You can see this in action by searching for Fizz Web Design on a Smartphone. You should be redirected to our mobile version.

I gave a solution for all those suffering a similar fate which you can read here.

Recently it’s started happening again..

htaccess file code broken by server update

Free Virtual Servers, while making server-side software changes automatically added a hashtag symbol at the beginning of one of my htaccess files – changing it from:

Select Code
AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .html .htm


Select Code
# AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .html .htm

The result being that the parsing of my html site for php was instantly broken, resulting in php code error at the top of the page, pushing down my content. Not very aesthetically pleasing and I’m sure if allowed to go unnoticed, not so good for your site’s SEO, if you want to adhere to Google’s guidelines on web designing for smartphones.

Removing the hashtag corrected the issue but – a few days later the same problem, an ugly piece of code sitting at the top of my site and the menu pushed down into the content. Now I was getting annoyed – this is my code and I want it to remain as it is because my htaccess file does things very specific to my site’s way of working.

This time a solution was found – to make the htaccess file immutable. That meaning that it can’t be modified thus protecting it from changes and random hashtags being added that break the code. All good I can relax now I thought.

Wrong. Less than 24 hours later the site stops loading, showing a 500 internal server error.

I raised a ticket with Free Virtual Servers immediately, and got the response that:

“We have made some serverwide changes and as a result you need to remove the FCGI entries in htaccess file.”

Well that’s just great, once again pretty standard practice in using the htaccess file to redirect to the mobile version of a site has been broken by Free Virtual Servers. Absurdly, you may recall from the previous article (linked at the beginning) that it was FVS who added the FCGI code to correct the break in the code that their server changes had caused before!

A threat to move all sites from FVS and some nagging got the explanation that:

“…we had to switch the server back to suPHP due to continued problems we had with FCGI.”

So FCGI code no longer works. Fortunately this particular service desk individual added the relative code himself to correct the issue – at least until it happens again.. The code to parse your site on Free Virtual Servers as php is now as follows:

Select Code
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml .htm .html

My recommendations
Quite simple: if you use a separate mobile site (via Mobile Detect code or a similar process) that your main site redirects to (usually recognised by replacing an m with www so the mobile site looks something like this: m.yoursite.com) and more specifically, if your site is an html site rather than a php site, then I would check that things are working as you would be expecting them to, because Free Virtual Servers give no direct warning to webmasters that such server changes might break your site. It may well be the same with other hosts.

Have you had similar problems parsing html as php or with htaccess files being altered without your knowledge? If so what was the outcome and how did you rectify the matter?

UPDATE: June 2015

Well, it’s happened again. All pages note showing on the World Wide Web – after much stern to’ing and fro’ing, it turns out that yet more server updates have been carried out by Free Virtual Servers which will potentially break sites parsing html as php via htacess files.

It seems the company exasperatingly has no system in place to email users out of courtesy to warn them this (rather large issue) may happen.

So here is the latest solution (although as always, we cannot guarantee it will work for you).

Select Code
AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .htm .html
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .php5
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .php4
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .php
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .php3
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .php2
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .htm
FcgidWrapper /usr/local/cpanel/cgi-sys/php5 .html

Share this..
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInPin on PinterestEmail this to someoneShare on TumblrShare on StumbleUponShare on Reddit

Tags: , , , , , , , , , , , , ,

6 Responses to “Host Server Updates Changing htaccess File”

  1. stub says:

    I’ve been with FVS for years now.

    However, the site mysteriously stopped processing php in html files, in a similar fashion to what you experienced.

    so having fired off an email to the helpdesk, and
    NO reply I took it on myself to fix the issue.

    evenutally i got this to work:

    AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .html .htm .shtml
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .htm
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
    FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .shtml

    and left it at that.

    then the site stopped working (again!) and i found the .htaccess file modified and the about lines commented (#) out. no update from FVS , just a site that didn’t work – again!!!

    fortunatly i came across your site, and used your recommendation:

    AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml .htm .html

    and this works (thankfully).

    i now need to send another email to FVS to tell them to stop messing with my site, and they have left it not functioning twice now. it makes you wonder…..

    • I’m glad it worked for you. You could ask FVS to make your htaccess files ‘immutable’ so that their updates (which can be pretty damaging without warning) don’t touch your htaccess files.
      The only danger is that, as I discovered, when they can’t access these files, any CRUCIAL changes therefore aren’t made and the site could simply be rendered as a blank page!
      I’ve no idea if other hosts are any better, but the only reasonable solution I found was to allow them access, keep backups and monitor constantly.

  2. stub says:

    Freevirtual servers keep amending my .htaccess file and KEEP altering the line:

    AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .html .htm .shtml


    #AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml .html .htm .shtml

    Which effectively disables the php rendering inside of a .html file. I uncomment it and it works again!

    I raise a ticket to say stop doing it and to either email me or call me and they just ignore me.

    Ridiculous customer service , so once this hosting has come to an end I will be looking for another ISP, I recommend others do!

Leave a Reply

Please complete the sum so we know you\'re a human... *