Home » Php » Enable PHP short open tags via .htaccess

Enable PHP short open tags via .htaccess

Posted by: admin April 23, 2020 Leave a comment


I’m currently running through a tutorial for a CMS system which unfortunately uses short open tags.

I’ve confirmed that my host will not allow these in their PHP config, but that they run PHP in Apache mode (as opposed to CGI). To the best of my knowledge, this should then allow me to set the short_open_tag flag to on in an .htaccess file.

However, this appears to not be working. In the root directory, I’ve created an .htaccess file with just the following line, but the short open tags are still being ignored.

php_flag short_open_tag on

Am I doing something wrong? If not, can anyone suggest why it may not be working? Thanks.

Note: Someone has marked this question as being answered somewhere else. Not only does the question identified not have an accepted answer, it’s based around and PHP config running in CGI mode, not Apache mode.

How to&Answers:

Try this

 <IfModule mod_php5.c>
   php_value short_open_tag 1

This would solve the problem


For .htaccess it should be php_value short_open_tag 1
For an ini file it’s short_open_tag=On.

If it doesn’t work in the .htaccess then you could try to add you own php.ini in you site root. That said it’s unlikely to work.

Simply put the server admin could have completely disabled this functionality and no matter what you add you will not be able to activate it. It’s best you ask your host and save yourself the pain.