.htaccess for PHP (Laravel) apps got changed in shared hosting

I encountered an error which seemed quite weird (at least to me).

I’ve been hosting a couple of Laravel apps on a shared server. Today, I noticed that these apps were not working, returning 403 errors.
Then, I saw that .htaccess files were wrongly configured.

Here’s the wrong .htaccess.

<FilesMatch ".*\.(phtml|php|PhP|php5|suspected)$">
Order Allow,Deny
Deny from all
</FilesMatch>

After the wrong code above was replaced with the following codeā€¦

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        # Removes index.php from ExpressionEngine URLs
        RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
        RewriteCond %{REQUEST_URI} !/system/.* [NC]
        RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

        # Directs all EE web requests through the site index file
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

… the apps started to work again.

The question is: Is it possible for a file like .htaccess to be changed in a shared server?

I contacted the hosting company, and the answer was…

  1. We noticed that you are on XXX hosting plan, we do not make any changes on customer files including .htaccess without informing.
  2. In case of .htaccess it is possible that changes can be appended to it in case of any PHP version or settings changes via cPanel >> PHP selector.
  3. It is also possible that in case of any application-level changes or plugin updates, the corresponding rules can get modified in .htaccess file too.

In my case, the error was probably caused by updating the PHP version.

Today’s lesson: updating PHP may change .htaccess files.

Leave a Reply

Your email address will not be published. Required fields are marked *