Dynamic 301 redirects
Hi,
Anyone who knows a good way to setup 301 redirects for dynamic generated items? I've read too much this evening I think to come up with something good.
Thanks anyway,
Daniel
Hello Daniel,
Would it be possible to share some more details regarding the exact scenario you have in mind, please?
I need to do this too, and here's what I'm planning...
1) Create a new custom field (long text) with the plain textarea box picked (not the radeditor), call it multipleUrls
2) Copy the Title\ExampleText from the page properties UI :)
Then in an HttpModule do a search for matches, and then redirect to
the detail view of the appropriate item. What's undecided for me is if
I'll use the API or some custom SP to boost speed (assuming there's any noticeable difference)
...essentially copy what the page properties does. The reason I like this is because I should be able to add a custom sidebar filter to show me content items that have or do not have this field filled out.
I do wish this was somehow native though...
Well, I have the following situation:
Does the new site need to redirect to the old site, or just support the legacy URL format?
Hi MB,
No it just needs to support the legacy urls.
---
Daniel
I think that can be done fairly easily using the IIS URL Re-Write module.
www.iis.net/.../url-rewrite
Basically, you want a rule something like this: (paste into the <system.webserver> section of web.config, once you have installed the IIS URL ReWrite module)
<rewrite>
<rules>
<clear />
<rule name="ReDirect Old Product URLs">
<match url="^products/product-detail\.aspx\?product_id=([0-9a-z-_]+)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="products/detail?pid=R:1" />
</rule>
</rules>
</rewrite>
Note: This is quite specific, and you might need to adjust it to suit your needs, but there is a pattern-match tester built into the re-write module so that you can play with it.
Essentially, it's looking for your old URL format (the protocol and host is ignored) and saving the bit after the ?product_id=
It then redirects to the new URL using the saved item as part of the new URL.
HTH.