Support

Admin Tools

#39515 .htaccess Maker does not include handler for php

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
4.3.4
PHP version
8.2
Admin Tools version
7.4.1

Latest post by nicholas on Sunday, 24 September 2023 14:26 CDT

0dries

A site was created on a temporary location. Admin tools, including the generation of .htacess, worked great there. The site was then successfully moved using Akeeba Backup. All worked fine, both front and back.

 

I now wanted to add an exception, and added an entry under "Allow direct access to these files". Clicking the button "Save and create .htaccess" gave two messages:

The new .htaccess has been written to disk
An error has occurred.
0 syntax error

In the back-end, everything refuses to load; in the front-end, I get an empty page containing just the error message

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0

 

The problem is resolved (after restoring a working version from .htaccess.admintools) by adding the line

AddHandler application/x-httpd-php82 .php .php5 .php4 .php3

to "Custom .htaccess rules at the bottom of the file".

 

This line was present automatically (without needing to use a custom rule) in the file .htaccess, as it was generated by Admin Tools on the temporary location. I don't understand why the very last line was chopped off from the file .htaccess on its final location, nor why the line is necessary. The site has been set to use PHP 8.2.10 via my hosting provider (a manual change set through my hosting provider who uses PHP 7.4.33 by default).

 

nicholas
Akeeba Staff
Manager

If you read the documentation on “Custom .htaccess rules at the bottom of the file” you will see that I have already answered your question there.

This line was added by your host when you chose to switch your site to PHP 8.2. However, your host only adds this line only when you change the PHP version through their hosting control panel.

Once you regenerate the .htaccess file with the .htaccess Maker you overwrite your .htaccess file with a new one.Your host does not apply that line automatically.

One solution would be to go back to your hosting control panel and switch your PHP version twice, e.g. from 8.2 to 8.1, save, then from 8.1 to 8.2, then save again. This is not a very good solution.

Therefore, we added the “Custom .htaccess rules at the bottom of the file” feature to the .htaccess Maker back in 2010 to help you with that. You copy that special line your host adds to the .htaccess file to enable a specific PHP version into the “Custom .htaccess rules at the bottom of the file”. From that point on, the .htaccess Maker transcribes that verbatim at the bottom of the newly generated .htaccess file.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

0dries

Very interesting, thank you for this clarification.

 

A follow-up question: When bringing up the new site on a temporary location:

First, the PHP version was set to 8.2;
Second, the Joomla installer was run;
Third, Admin Tools was installed;
Fourth, the .htaccess file was recreated by Admin Tools (numerous times, actually).

At each re-generation, the last line, the PHP handler, was kept in place. It was only after migrating the new site to its final location that this line was not kept. The difference in behavior is odd. Would there be an explanation for this, or are you tempted to classify this as a case of PEBKAC (which is fine by me, as your explanation/documentation makes sense and I'm happy to have it resolved in the proper way)?

 

KR,

 

nicholas
Akeeba Staff
Manager

See, the critical information you're not telling me here and you're not considering yourself is that you were developing the site in a subdirectory (or a subdomain whose web root was a subdirectory of the main site; the same thing applies). 

First, the PHP version was set to 8.2;

This create a .htaccess file in the main web root of the domain.

Second, the Joomla installer was run

This has no effect on the .htaccess file in either the main web root, or the subdirectory where you installed your site, because Joomla! neither comes with one, nor does it ever create a .htaccess file.

Remember, merely Joomla! ships an inert file (htaccess.txt, ignored by your web server) which you'd have to rename to .htaccess yourself to enable SEF URLs.

Third, Admin Tools was installed;

This created a new .htaccess file in the folder where you had installed your site.

Fourth, the .htaccess file was recreated by Admin Tools (numerous times, actually).

At this point the .htaccess file was overwritten, in the folder where you had installed your site. Same as above.

At each re-generation, the last line, the PHP handler, was kept in place.

Nope, there was never a PHP handler line in the .htaccess file in your site's subdirectory.

You seem to forget that .htaccess files cascade over filesystem folders, as per the official documentation of Apache, your web server.

If you are developing on a subdirectory, regenerating the .htaccess file with Admin Tools only overwrites the .htaccess file in the subdirectory. It does NOT touch the .htaccess in the main web root folder (one folder level above your site) which is where your host had created the .htaccess file in your first step.

Moreover, since .htaccess files cascade, that sole line on that .htaccess file in the main web root was also applied to your site in the subdirectory. So, you got PHP 8.2 despite the fact the .htaccess file in your site's subdirectory never had that line, because that line was cascaded (inherited) from the .htaccess file one folder level above your site.

It was only after migrating the new site to its final location that this line was not kept.

At this point you moved your site from a subdirectory to the site's root. By doing so you replaced the .htaccess file in the site's root.

However, you used Akeeba Backup to do it which means that you also used Kickstart. Kickstart, together with Akeeba Backup's restoration script (ANGIE) can handle that PHP handler automatically, transcribing it to the bottom of the .htaccess file as it is extracted. In fact, the .htaccess file in the backup archive is always extracted as htaccess.old so as not to interfere with the restoration process, and gets renamed back to .htaccess (and has the PHP handler line transcribed) at the very last step of the restoration script. This is a simple mechanism we have in place that works on ~99% of sites to prevent users shooting themselves in the foot, as you were about to do. I guess it works a bit too well because you never noticed.

The next time you used Admin Tools to regenerate a .htaccess file, it overwrote that file with a new one which no longer had the AddHandler line, hence your problem.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!