Frage

I'm running a legacy website which has a tonne of 301 redirects on it. In an effort to make my life simpler, I switched them from doing manual 301 redirects in IIS to using the url rewriting module and a rewrite map, which I can generate from the database.

Unfortunately I've now hit a snag, in that some of their urls come with querystrings (from Google's adwords), and these invariably 404 (because they don't match the urls in my rewrite map).

Is there a way around this, or do I have to go back to manually doing the 301s?

For the record: we're using IIS7

Code samples:

url: http://mydomain.com/widgets/?gclid=[google code]

Rewrite Rule:

<rule name="Rewrite rule1 for News301Redirects" stopProcessing="false">
   <match url=".*" />
   <conditions>
       <add input="{News301Redirects:{REQUEST_URI}}" pattern="(.+)" />
   </conditions>
   <action type="Redirect" redirectType="Permanent" url="{C:1}" appendQueryString="false" />
 </rule>

Map Line:

<add key="/widgets/" value="/widgets.asp" />
War es hilfreich?

Lösung

Well, the answer proved to be depressingly simple - just an absolute pig to find.

Instead of using REQUEST_URI (which gets the whole requested URL, including the querystring) I've switched to using URL (which just gets the URL without the querystring) and that seems to have utterly resolved my problems.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top