如何根据主机名在.htaccess上设置php_值?

如何根据主机名在.htaccess上设置php_值?,php,apache,.htaccess,xampp,wamp,Php,Apache,.htaccess,Xampp,Wamp,在我的web服务器中,我在.htaccess中添加了一些行来设置php_值。.htaccess代码如下所示: <IfModule mod_php5.c> php_value auto_prepend_file '\var\prevalue.php' </IfModule> <IfModule mod_php7.c> php_value auto_prepend_file '\var\prevalue.php' </IfModule>

在我的web服务器中,我在.htaccess中添加了一些行来设置php_值。.htaccess代码如下所示:

<IfModule mod_php5.c>
    php_value auto_prepend_file '\var\prevalue.php'
</IfModule>
<IfModule mod_php7.c>
    php_value auto_prepend_file '\var\prevalue.php'
</IfModule>

php\u value auto\u prepend\u文件'\var\prevalue.php'
php\u value auto\u prepend\u文件'\var\prevalue.php'
如何为特定的主机(如xyz.com)执行此操作


请告知我未测试

,但您可以使用
如果
HTTP\u主机

<If "%{HTTP_HOST} == 'xyz.com'">
    php_value auto_prepend_file '\var\prevalue.php'
</If>
<Else>
    php_value auto_prepend_file '\var\otherprevalue.php'
</Else>

php\u value auto\u prepend\u文件'\var\prevalue.php'
php\u value auto\u prepend\u文件'\var\otherprevalue.php'
或:


php\u value auto\u prepend\u文件'\var\prevalue.php'
php\u value auto\u prepend\u文件'\var\otherprevalue.php'

有一个。

未经测试,但您可以将
if
HTTP\u主机一起使用:

<If "%{HTTP_HOST} == 'xyz.com'">
    php_value auto_prepend_file '\var\prevalue.php'
</If>
<Else>
    php_value auto_prepend_file '\var\otherprevalue.php'
</Else>

php\u value auto\u prepend\u文件'\var\prevalue.php'
php\u value auto\u prepend\u文件'\var\otherprevalue.php'
或:


php\u value auto\u prepend\u文件'\var\prevalue.php'
php\u value auto\u prepend\u文件'\var\otherprevalue.php'

有一个。

当使用php_值时,您是否收到内部服务器错误消息?您的Apache版本是什么?当使用php_值时,您是否收到内部服务器错误消息?您的Apache版本是什么?它可以工作。非常感谢。我的最后一个脚本是:php\u value auto\u prepend\u file'\var\prevalue.php'php\u value auto\u prepend\u file'\var\prevalue.php'它可以工作。非常感谢。我的最后一个脚本是:php\u value auto\u prepend\u file'\var\prevalue.php'php\u value auto\u prepend\u file'\var\prevalue.php'