我在我自己的 Centos 服务器上设置了 Apache 和几个虚拟网络服务器,我希望只为位于 /var/www/ostickets/html< 的那些网络服务器中的一个启用 PHP 短标签
。我可以通过将 short_open_tag=On
添加到 php.ini 来成功启用短标签,但是,我不希望在全局范围内这样做,而只希望在一个站点上这样做。我尝试了以下操作,但是没有显示任何内容。我查看了各种日志,但无法检测到任何错误。是否有可能我无意中禁用了这样做的能力,如果是这样,我该如何允许它(引用“如果您无权访问 php.ini,您可以尝试通过 .htaccess 文件启用它们,但是如果您使用的是共享主机,托管公司可能会禁用此功能:").
[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]#
最佳答案
您是否为此目录配置了 Apache 指令 AllowOverride All
?
关于php - 使用 .htaccess 启用 PHP 短标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19116823/