IfDefine and RewriteBase doesn't work well together

☆樱花仙子☆ 提交于 2019-12-02 16:50:09

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/53712313/ifdefine-and-rewritebase-doesnt-work-well-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!