Aminah Nuraini
Aminah Nuraini

Reputation: 19196

IfDefine and RewriteBase doesn't work well together

When I use this code, it works just okay:

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

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

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

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?

Upvotes: 0

Views: 158

Answers (1)

anubhava
anubhava

Reputation: 785866

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

You need to use it as:

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

<IfDefine !ServerBase>
    RewriteBase /
</IfDefine>

Note use of ServerBase instead of ${ServerBase}.

Check official Apache doc of IfDefine

Upvotes: 0

Related Questions