【发布时间】:2021-07-29 16:09:02
【问题描述】:
我需要专门处理一个查询参数。 网址可能如下所示:
https://example.com/?app=egov&map=1337
https://example.com/?app=egov&map=1337&showoptions=true
https://example.com/?app=egov&map=1337&showoptions=true&anotherparam=helloWorld
重定向应该指向
https://example.com/contextName/resources/apps/egov/index.html?map=1337
https://example.com/contextName/resources/apps/egov/index.html?map=1337&showoptions=true
https://example.com/contextName/resources/apps/egov/index.html?map=1337&anotherparam=helloWorld
如您所见,app-Parameter 需要用作 URL 部分;其他的需要像传统的查询参数一样使用。
我已经想通了,如何实现第一部分,其中https://example.com/?app=egov 使用以下内容指向https://example.com/contextName/resources/apps/egov/index.html
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^app\=(.+)
RewriteRule ^/$ "/contextName/resources/apps/%1/index.html" [R,L,QSA]
但我正在努力如何实现对其他参数的正确处理。
【问题讨论】:
标签: regex apache redirect mod-rewrite parameters