Nginx的重写URL更换为Apache重写 [英] Nginx Rewrite URL replacement for Apache rewrite
本文介绍了Nginx的重写URL更换为Apache重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何转换的 nginx的以下等价URL重写:
重写规则^读/([0-9] +)/ $ /读/?U = $ 1 [QSA,L]
解决方案
您可以通过两种方式做到这一点,与位置:
#在< U>分配捕获$ U。一些老的pcres需要P< U>
位置^ /读/(LT; U> [0-9] +)?/ $ {
重写^ /读/ U = $ U最后?;
}
或只是一个重写:
改写^ /读/([0-9] +)/ $ /读/ U = $ 1的最近?;
nginx的将追加默认查询字符串(您可以通过添加另一个?在重写目标年底禁用行为)。
How do I convert nginx equivalent URL rewrite for the following:
RewriteRule ^read/([0-9]+)/?$ /read/?u=$1 [QSA,L]
解决方案
You can do this in two ways, with a location:
# the ?<u> assigns the capture to $u. Some older pcres need ?P<u>
location ^/read/(?<u>[0-9]+)/?$ {
rewrite ^ /read/?u=$u last;
}
or with just a rewrite:
rewrite ^/read/([0-9]+)/?$ /read/?u=$1 last;
nginx will append the query string by default (you can disable the behavior by adding another ? at the end of the rewrite target).
这篇关于Nginx的重写URL更换为Apache重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文