棘手的Apache重写配置 [英] tricky apache rewrite configuration

查看:53
本文介绍了棘手的Apache重写配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个格式为

http://example.com /fetchjobs.action?jobType=crons&jobList=foo&categoryModeId=0&showOnlyLatest=true

我想将url上方重定向到url下方

And I want to redirect above url to url below

http://newexample.com/crons?jobList=foo& ; categoryModeId = 0& showOnlyLatest = true

注意:

  1. 域已从example.com更改为newexample.com.

  1. domain got changed from example.com to newexample.com.

"jobType"的值现在位于URL路径中,而不是查询参数. (jobType = crons与/crons?)

Value of "jobType" is in a URL path now instead of query param. (jobType=crons vs /crons?)

所有其他查询参数都保留为新URL中的查询参数.

All other query parameters are retained as query params in a new URL.

源URL中可以有任意数量的查询参数.

There can be any number of query parameters in source URL.

这里的铅表示赞赏.

推荐答案

尝试一下:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)?jobType\=([^\&]+)&?(.*)?$
RewriteRule ^     http://newsite.com/%2??%1%3  [L,R=301,NE]    

注意:清除浏览器将其缓存测试.

Note: clear browser cache the test it .

这篇关于棘手的Apache重写配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆