tricky apache rewrite configuration

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

I have a URL of the form

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

And I want to redirect above url to url below

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

Note:

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

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

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

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

Leads here is appreciated.

回答1:

Try this :

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

Note: clear browser cache the test it .



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