Hi Guys
We have a customer that has moved from an old DW solution to a new DW solution (Fresh database).
On their old solution they shared it with a different brand, and therefore their page IDs startet at around 4000+.
Since they used the old URLs Google has indexed a lot of /Default.aspx?ID=4320 urls, and we want thise old mapped to their new corresponding pages.
Since DirectPaths isn't triggered when calling "/Default.aspc?ID=4320", we can't use that to do it. We don't have server access, so we can't do in on the IIS.
Which probably means that we have to create a custom module to handle this.
So i figured that i could create a notification that runs on PageLoad and check if the current ID is one of the old and then redirect to the new page, but i can't find a notification that fires when i hit the 404 page.
Is this true? Is there no subscriber for the 404 page?
Regards
Martin
Developer forum
E-mail notifications
Mapping old PageIDs to new IDs (DW8)
Martin Nielsen
Posted on 07/05/2012 10:04:05
Replies
Pavel Volgarev
Posted on 09/05/2012 10:04:48
Hi Martin,
Unfortunately, there is no notification for that. What you could try is to specify a custom 404 handler under "HTTP 404" in your area settings. Set it to an internal page and write a notification subscriber (or custom module) that will trigger only for this page and make a redirect.
In a meanwhile I will create a work item for this (notifications from 404 handler).
-- Pavel
Unfortunately, there is no notification for that. What you could try is to specify a custom 404 handler under "HTTP 404" in your area settings. Set it to an internal page and write a notification subscriber (or custom module) that will trigger only for this page and make a redirect.
In a meanwhile I will create a work item for this (notifications from 404 handler).
-- Pavel
Morten Bengtson
Posted on 09/05/2012 11:06:53
Alternatively, you can add a rule in your web.config for each of the pages you want to redirect.
Redirect with IIS7
Place the following within the system.webServer section in web.config...
The regular expressions used in the example may need to be modified slightly for your needs.
You should probably make sure that there will be no conflict with new pages, e.g. customer creates a new page that has same id as an old page.
To avoid this, you can change the identity seed on the PageID column in Page table to something higher than the old page ids.
Redirect with IIS7
Place the following within the system.webServer section in web.config...
<rewrite> <rules> <!-- add a rule for each redirect --> <rule name="redirect_old_page_4320" stopProcessing="true"> <match url="^Default\.aspx$" ignoreCase="true" /> <conditions> <!-- match the old page id (4320) --> <add input="{QUERY_STRING}" pattern="^ID=4320(&.*)*$" ignoreCase="true" /> </conditions> <!-- redirect to the new page id (123) - or a friendly url --> <action type="Redirect" redirectType="Permanent" url="/Default.aspx?ID=123{C:1}" appendQueryString="false" /> </rule> </rules> </rewrite>
You should probably make sure that there will be no conflict with new pages, e.g. customer creates a new page that has same id as an old page.
To avoid this, you can change the identity seed on the PageID column in Page table to something higher than the old page ids.
Martin Nielsen
Posted on 09/05/2012 11:44:57
Thank you both for the ideas, I will try Pavel's suggestions first, since i planned on making this a reusable module for Dynamciweb.
Resorting to rewrite rules in web.config would make it hard for less geeky people to do it, but if it comes to it, i might have to go that way.
Resorting to rewrite rules in web.config would make it hard for less geeky people to do it, but if it comes to it, i might have to go that way.
Martin Nielsen
Posted on 10/05/2012 11:10:49
Hi Pavel,
Do you know if it's possible to use Rewrite rules on your DW free/Express server?
AFAIK you requires a module installed on the IIS.
// Martin
Do you know if it's possible to use Rewrite rules on your DW free/Express server?
AFAIK you requires a module installed on the IIS.
// Martin
Pavel Volgarev
Posted on 10/05/2012 11:26:32
Hi Martin,
URL rewrite module is not part of the IIS and should be installed separately (if you're asking about this). If it's installed, it doesn't matter what version of Dynamicweb you're using.
-- Pavel
URL rewrite module is not part of the IIS and should be installed separately (if you're asking about this). If it's installed, it doesn't matter what version of Dynamicweb you're using.
-- Pavel
Martin Nielsen
Posted on 08/06/2012 12:53:25
Hi Morten,
I've installed URL Rewrite on server, and created this rule.
But when i access the url www.domain.com/Default.aspx?ID=1059 i get DWs standard 404 page.
Is it a problem that i want to redirect a URL when there's already a file of that name?
//Martin
I've installed URL Rewrite on server, and created this rule.
<rewrite> <rules> <rule name="rule1" patternSyntax="ExactMatch" stopProcessing="true"> <match url="Default.aspx?ID=1059" /> <action type="Redirect" url="/priser-finansering/behandling-i-tide.aspx" redirectType="Permanent" /> </rule> </rules> </rewrite>
Is it a problem that i want to redirect a URL when there's already a file of that name?
//Martin
Morten Bengtson
Posted on 08/06/2012 13:32:30
This post has been marked as an answer
Hi Martin,
Your rewrite rule is not triggered because the request does not match.
I'm pretty sure that you cannot match on query string values like you are trying to, because the match url is only checking the path of the request, e.g. "Default.aspx". You need to add a separate condition for QUERY_STRING.
Also, the url you specify on the match element is actually a regular expression pattern, so you need to escape characters that have special meaning in regular expressions, like . (dot).
Try this...
URL Rewrite Module Configuration Reference
Your rewrite rule is not triggered because the request does not match.
I'm pretty sure that you cannot match on query string values like you are trying to, because the match url is only checking the path of the request, e.g. "Default.aspx". You need to add a separate condition for QUERY_STRING.
Also, the url you specify on the match element is actually a regular expression pattern, so you need to escape characters that have special meaning in regular expressions, like . (dot).
Try this...
<rewrite> <rules> <rule name="rule1" stopProcessing="true"> <match url="^Default\.aspx$" ignoreCase="true" /> <conditions> <add input="{QUERY_STRING}" pattern="^ID=1059(&.*)*$" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Permanent" url="/priser-finansering/behandling-i-tide.aspx" appendQueryString="false" /> </rule> </rules> </rewrite>
URL Rewrite Module Configuration Reference
Votes for this answer: 0
Martin Nielsen
Posted on 11/06/2012 13:18:09
Hi Morten,
Thank you for the snippet. I tried it and it worked out great.
And thank god for Notepad++ and it's macros, changed all my wrong rules to the new format in 5 minuts :-)
// Martin
Thank you for the snippet. I tried it and it worked out great.
And thank god for Notepad++ and it's macros, changed all my wrong rules to the new format in 5 minuts :-)
// Martin
Martin Nielsen
Posted on 31/08/2012 12:05:12
Hi Pavel,
Did we ever get the notification for 404 pages?
// Martin
Did we ever get the notification for 404 pages?
// Martin
Pavel Volgarev
Posted on 31/08/2012 13:07:24
Hi Martin,
It's implemented as per #8563 ("Make it possible to receive notifications from 404 handler"). The new notification is Notifications.Standard.Page.NotFound and the corresponding event arguments type is Notifications.Standard.Page.NotFoundArgs.
This will be available in 8.2.
-- Pavel
It's implemented as per #8563 ("Make it possible to receive notifications from 404 handler"). The new notification is Notifications.Standard.Page.NotFound and the corresponding event arguments type is Notifications.Standard.Page.NotFoundArgs.
This will be available in 8.2.
-- Pavel
Martin Nielsen
Posted on 31/08/2012 13:11:52
Great, looking forward to it :-)
Imar Spaanjaars
Posted on 08/09/2012 15:47:10
FYI: I also added support for these notification to the Dynamicweb templates for Visual Studio. Should be out with version 1.7.1 and later.
Imar
You must be logged in to post in the forum