4

I have Apache set up on my own Centos server with several virtual web servers, and I wish to enable PHP short tags for only one of those web servers which is located at /var/www/ostickets/html. I can successfully enable short tags by adding short_open_tag=On to php.ini, however, I don't wish to globally do so, but only the one site. I've tried the following, however, nothing is displayed. I've looked at various logs, and cannot detect any errors. Is it possible that I inadvertently disabled the ability to do so and if so how do I allow it (reference "If you don't have access to the php.ini you can try to enable them trough the .htaccess file but it's possible the hosting company disabled this if you are on shared hosting:").

[root@vps html]# pwd
/var/www/ostickets/html
[root@vps html]# ls -la .hta*
-rw-r--r-- 1 root root 60 Oct  1 07:38 .htaccess
[root@vps html]# cat .htaccess
# php_flag short_open_tag on

php_value short_open_tag 1



[root@vps html]# cat test.php
<? echo('Hello World');?>
[root@vps html]#

2 Answers 2

4

Have you Apache directive AllowOverride All configured for this directory ?

Sign up to request clarification or add additional context in comments.

4 Comments

No, Can you please elaborate?
AllowOverride directive is used to define which configuration you can override in .htaccess files. Maybe this directive is missing or missconfigured in your global apache configuration, that's why php_value directive in .htaccess are ignored.
Thanks Koryonik, AllowOveride All worked. A while back, I put all my virtual servers in /var/www/virtualServer1/html, /var/www/virtualServer2/html, etc.I think my default configuration assumed only one /var/www/html. Is adding AllowOveride Allto <Directory /> to lose and might be a security issue?
why not set this directive to <Directory /var/www/> ? Another way would be to configure per virtual host.
2

Sometimes when we don't have access to modify configurations on server like in php.ini file and we still need to enable short tags for our php code. We can do it by .htaccess file. If you have not created any .htaccess file yet, create one in root directory of your website and add

php_value short_open_tag 1

That's it for .htaccess file.

Now if you want to enable that using php.ini and if you can...

just set

 short_open_tag=On

in php.ini at server and you are done..

If still it is not enabled contact your hosting support.

1 Comment

Thanks Krishnadas, but I tried each of those as described by my original post, and I am "hosting support".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.