简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM