标签:nginx redirect rewrite forum ipb
我正在使用IPB论坛.我设法使用友好的网址与nginx服务器配置修改.但是,我需要将旧论坛的URL重定向到重定向器php文件,以获取主题(或论坛,成员等)的当前URL.例如:如果url类似于/forum/index.php?board=23,我将重定向到redirector.php.
这是我目前的配置,能够在IPB上使用友好的URL
location /forum {
try_files $uri $uri/ /forum/index.php;
rewrite ^ /forum/index.php? last;
}
当我在这个位置块中插入if语句时,如下所示,我无法检索查询参数“board”.
location /forum {
if ($arg_board != "") {
rewrite ^ /redirector.php?q=$arg_board break;
}
try_files $uri $uri/ /forum/index.php;
rewrite ^ /forum/index.php? last;
}
这里缺少什么?
解决方法:
你的问题与使用break而不是last.从文档:
http://wiki.nginx.org/HttpRewriteModule#rewrite
last – completes processing of current rewrite directives and restarts the process (including rewriting) with a search for a match on the URI from all available locations.
break – completes processing of current rewrite directives and non-rewrite processing continues within the current location block only.
由于您没有在/ forum位置块中为/ redirector定义处理程序,因此if(..){rewrite}不会执行您想要的操作.将该断点设为最后一个,以便重写可以触发相应的位置块.
标签:nginx,redirect,rewrite,forum,ipb 来源: https://codeday.me/bug/20190630/1333544.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。