Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

redirect - IIS rewrite rule not passing parameters

I have redirects currently set up to go from oldsite.com to newsite.com using a rewrite map. They work except when a parameter is passed through the URL, ex. http://oldsite.com?utm_source=go.wayne.edu&utm_medium=direct&utm_campaign=quick-access&utm_content=, still goes to the old page instead of redirecting to the new page with the parameters, ex. http://newsite.com?utm_source=go.wayne.edu&utm_medium=direct&utm_campaign=quick-access&utm_content=.

Here's my code:

            <rule name="Redirects to New Site">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{RelaunchRedirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="http://newsite.com/{C:0}" appendQueryString="true" redirectType="Permanent" />
            </rule>

Still very new to all of this and I can't figure out why the parameters are not passing. I've seen some similar cases on here but haven't been able to get those solutions to work for me.

Any ideas on what I can do to make this work?

question from:https://stackoverflow.com/questions/66067332/iis-rewrite-rule-not-passing-parameters

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can try to use this URL Rewrite rule:

       <rewrite>
            <rules>
                 <rule name="Redirects to New Site" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                    </conditions>
                    <action type="Redirect" url="http://newsite.com{URL}" appendQueryString="true" redirectType="Permanent" />
            </rule>
            </rules>
        </rewrite>

enter image description here

Feel free to let me know if there are any questions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...