本文介绍了IfDefine和RewriteBase不能很好地协同工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用此代码时,它可以正常工作:

When I use this code, it works just okay:

<IfDefine ${ServerBase}>
    RewriteBase ${ServerBase}
</IfDefine>

但是当我添加它时,它总是使用RewriteBase \,这不是我想要的.

But when I add this, it always uses RewriteBase \ which was not what I want.

<IfDefine !${ServerBase}>
    RewriteBase /
</IfDefine>

条件已经不同.定义ServerBase时之一,而未定义ServerBase时之一.如何在RewriteBase中使用IfDefine else模式?

The condition was already different. One of them when ServerBase is defined and one of them is when ServerBase is NOT defined. How can I use IfDefine else pattern with RewriteBase?

推荐答案

IfDefine检查是否定义了参数.它不会检查它的值.

IfDefine checks whether a parameter is defined or not. It doesn't check it's value.

您需要将其用作:

<IfDefine ServerBase>
    RewriteBase ${ServerBase}
</IfDefine>

<IfDefine !ServerBase>
    RewriteBase /
</IfDefine>

请注意使用ServerBase而不是${ServerBase}.

检查IfDefine 的Apache官方文档

Check official Apache doc of IfDefine

这篇关于IfDefine和RewriteBase不能很好地协同工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 05:36