Coder Social home page Coder Social logo

iamandycohen / urlrewrite Goto Github PK

View Code? Open in Web Editor NEW
23.0 5.0 67.0 124.68 MB

Sitecore module that allows Content Author's to author inbound and outbound url redirects and rewrites.

License: MIT License

C# 96.43% CSS 0.05% JavaScript 0.44% ASP 3.08%

urlrewrite's Introduction

Url Rewrite

While there are many Redirect / Rewrite modules available in the Sitecore Marketplace, I created this one to address the fact that most of them cannot create redirects that are Site specific.

In addition to adding Site specific redirect capabilities, I have modeled the data structure to closely match the functionality of Microsoft's IIS Url Rewrite plugin.

*** This module is not supported if you are using xDB Cloud Edition *** Sitecore Support: "Creation of custom segments is not supported by the Experience Analytics in the xDB Cloud service. This should be fixed in a future service update." https://kb.sitecore.net/articles/966080

Changelog

Varsion 1.8.2 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.8.2

  • Added support for Sitecore 8.2

Varsion 1.8.1.3 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.8.1.3

  • Added support for Sitecore 8.1 Update 2 & Update 3
  • Fixed sort order thanks to Dan Sinclair
  • Fixed RulesEngine.GetRedirectFolderItems so that it only returns Redirect Folder templates

Version 1.8 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.8

  • Added reporting via analytics
  • added Url Rewrite to Experience Analytics Dashboard
  • Added prefetching of UrlRewriter item
  • Moved all templates from User Defined folder to System Modules
  • Removed unused references
  • Fixed logic for allowing multiple rules to be processed during a request when a Redirect field "Stop Processing of Subsequent Rules" is set to false
  • Package now installs to master and web

Version 1.7.2 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.7.2

  • Fixed potential for a redirect loop if you have a database problem, you are using the html extension on the handler, and you have a custom error page that is pointing to an html page
  • Changed initialization of rules into an initialization pipeline
  • Removed reporting
  • Changed error handling of 404's on a static file redirect
  • Fixed rebuilding of cache on save, publish or delete - no longer need to restart IIS to refresh the rules.
  • Added missing update to Default.aspx for UrlRewrite tester

Version 1.7.1 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.7.1

  • Fixed missing reporting item in the web database that prevented publishing from working after installing the module.

Version 1.7 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.7

  • Added outbound rules
  • Added ability to set response headers
  • Added inbound rule rewrite action
  • General cleanup
  • Added Sample Rewrites
  • Added hit count tracking

Version 1.6 - https://github.com/iamandycohen/UrlRewrite/releases/tag/v1.6

  • Added information about conditions to the Url Rewrite application in the Sitecore Admin UI
  • Fixed UrlRewriteHandler displaying blank page if the StaticMapHandler didn't find the file. Allowed exceptions to be bubbled up.
  • Added a new type of rediret action - Item Query Redirect which allows you to use a Sitecore Query to find an item. Ability to utilize back references from conditions.

Version 1.5

  • Added support for Custom Response
  • Added support for Abort
  • Added Bootstrap UI for testing the redirects and visually seeing how the rules are processed.
  • Fixed UrlRewriteHandler so that it calls the StaticFileHandler if it no rules are matched.
  • Added drop down list so you can select your site instead of having to type a regular expression to match the site on. NOTE *** All Redirect Folder's are currently reset so you have to reset the Site Name Restriction field.
  • Added the ability to have sub folders in a top level Redirect Folder
  • removed the top level Redirect Folder from the package so that rules don't get overwritten when you reinstall the package
  • Updated how back references work for Rules and Conditions
  • Fixed security on Redirect Workflow

Version 1.1

  • Major refactor to support instantiation of the UrlRewriter without needing HttpContext or a web site.
  • Supports Unit Tests.

Version 1.0

  • Initial Release

urlrewrite's People

Contributors

iamandycohen avatar sincladk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

urlrewrite's Issues

HttpException Server cannot append header after HTTP headers have been sent

Hi -

We are using the URL rewrite module to handle redirects from multiple old sites that now point to the new Sitecore site. The one issue we see is the logs have a lot of "_HttpException Server cannot append header after HTTP headers have been sen_t" errors. Has this been seen before or do we have something misconfigured perhaps?

Thanks,

Dave

Config file contains entries needed for both CM and CD servers

During the server installation process it would be nice if the URL Rewrite module's config settings were broken up into two different config files. Ideally, one of the configuration files would contain all of the settings that should not be present on the content delivery servers. This would allow the person doing the installation to easily disable one file for the installation, rather than commenting out and managing different sections of one file.

Multi Language

Hi,

We're seeing an issue with the redirect module where redirects created in one language version are affecting all languages. Unfortunately with CMS authors all around the world working independently we are getting issues with circular redirects for example:

https://www.dropbox.com/s/5khn17gtwf1cqw0/Screenshot%202018-04-09%2008.46.37.png?dl=0

This is one that a US author set up which works fine. But for the UK site the item that is being redirected to has a display name (which is used in the URL) of our-partnership-with-george-washington-university, which causes a circular redirect.

Is there anyway to limit a redirect to the language version it is created for? Or am I missing something?

Thanks,

James.

Redirect fails when using insert option to the 'Redirect Folder' template

Hi Andy,

I discovered an issue when using the Hi.UrlRewrite module.
I discovered that it is caused by the following code
var redirectFolderItems = db.GetItem(RedirectFolderItem.TemplateId).GetReferrers(); in RulesEngine.cs (line 148)

In my environment I added an insert option on my platform node in content to enable content managers to add a redirect folder, and this causes an additional referring item which does not have the field Site Name Restriction

It took me a while (I needed to download and debug your module) to find this. Simply removing the insert option solved my issue, but I think it might be wise that an additional check is being performed on templateName, before returning the redirectFolderItems?

Cheers,
Nico

Threads locking issue in Hi.UrlRewrite module

Hi Andy,
We had multiple site outages in past few weeks and accordingly we had registered few tickets with sitecore for each outage to find out the root cause. As per sitecore common issue in each outage is thread locking in Hi.UrlRewrite module. Have a look at attachment for more details.
Hi.UrlRewrite.docx

Please provide some direction on this what code changes would be required to mitigate this issue. Let us know if you need more information on this.

This is Sitecore.NET 8.1 (rev. 160519)

Is there anyway if we can disable this for time being as suggested by sitecore for analysis without having any impact in site
Right now we have set Hi.UrlRewrite.CacheSize value to 100MB. Should we increase this value?

Note: We provide memory dump / SSPG package to sitecore for investigation.

Thanks

Content Delivery Server (Azure WebApps) redirects are not working

Hi,

On our Content Delivery server the redirects are not working.

I've installed the module(v.1.8.2) on Sitecore 8.2 (rev. 161221) on a Azure Web Apps environment. On the Content Management Servers everything is working fine. The redirects are working and also the UrlRewriter module in sitecore is working fine for all databases (master and web).

However on the Content Delivery server the redirects are not working at all. I don't get any errors in the logs. The Hi.UrlRewrite.dll and the config files are existing on the Content Delivery server.

Any idea what could be going on and how I can fix this?

Issue with languages in URL

I am trying to put in a redirect with the pattern of "^old/page1$" so that I can redirect http://www.website.com/en/old/page1 to http://www.website.com/en/new/page2.

When I set my return URL to "http://{HTTP_HOST}/new/page2", I am redirected to http://www.website.com/new/page2 instead of http://www.website.com/en/new/page2.

I am working on a multilingual site (on Sitecore version 7.2), so I am not able to hard-code the return URL to http://www.website.com/en/new/page2.

Is there any way to carry over the language from the original URL? When I put the language into the pattern to match with the URL, it doesn't work.

Upgrade guide

Hi, could not find any guidelines. I am updating from Sitecore 7.2 to Sitecore 8.2.1
How can I update this module? When I install package with items - new rules (default) are added. Maybe it will be enough to just add new files and replace existent?

Unpublished item causes Sitecore errors

After installing the URLRewrite module the follow error was being written to the logs:
Exception: System.InvalidOperationException
Message: Root item /sitecore/system/Modules/Url Rewrite/Reporting is not defined for index UrlRewriteReporting in web database
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.IsNotNull(Object value, String message)
at Sitecore.Search.Crawlers.DatabaseCrawler.Initialize(Index index)
at Sitecore.Search.Index.AddCrawler(ICrawler crawler)

This can be resolved by publishing all related URL Rewrite items, however that is not defined in the installation steps and it may have been blocking the installation of another package.

Issue while building the reporting database

We are getting the following error on Sitecore 8.1 update -2 after installing the module, any help is highly appreciated.
Exception: System.TypeLoadException
Message: Derived method 'Filter' in type 'Hi.UrlRewrite.Analytics.ByUrlRewriteRedirect' from assembly 'Hi.UrlRewrite, Version=1.8.5779.17263, Culture=neutral, PublicKeyToken=null' cannot reduce access.
Source: mscorlib
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Sitecore.Reflection.ReflectionUtil.CreateObject(String assembly, String className, Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CreateObject(String typeName, Object[] parameters)
at Sitecore.ExperienceAnalytics.Core.Repositories.DimensionDefinitionService.CreateDimensionFromConfig(XmlElement childNode)
at Sitecore.ExperienceAnalytics.Core.Repositories.DimensionDefinitionService.LoadDimensionsFromConfig(String pathToConfigNode)
at Sitecore.ExperienceAnalytics.Core.Repositories.DimensionDefinitionService..ctor(String pathToConfigNode, ILogger logger)

Method not found: 'Sitecore.Caching.ICache Sitecore.Caching.CustomCache.get_InnerCache()'

Hi, First off thanks for the great module we have it on several installations and its been really great. I've just tried to install it on a Sitecore 8.0 (rev. 150812). I tried UrlRewrite 1.8 and 1.8.2 but just get this error in the log file.

6200 13:41:09 ERROR UrlRewrite::Exception during initialization.
Exception: System.MissingMethodException
Message: Method not found: 'Sitecore.Caching.ICache Sitecore.Caching.CustomCache.get_InnerCache()'.
Source: Hi.UrlRewrite
at Hi.UrlRewrite.Caching.RulesCache.SetRules[T](IEnumerable1 outboundRules, String key) at Hi.UrlRewrite.Caching.RulesCache.SetInboundRules(IEnumerable1 inboundRules) in C:\git\UrlRewrite\Hi.UrlRewrite\Caching\RulesCache.cs:line 31
at Hi.UrlRewrite.Processing.RulesEngine.GetCachedInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 257
at Hi.UrlRewrite.Processing.InboundRuleInitializer.Process(PipelineArgs args) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRuleInitializer.cs:line 30

Any ideas why it might be happening before we try debugging it ourselves?

Best Regards
Richard

Documentation?

Hi, I see the readme and several versions of the package, but I don't see the documentation. Am I looking in the wrong location?

Feature-request: overview page that lists all existing rules

Hi!

Our client has more than 500 redirect rules setup - it would be very nice with a page that lists all of the existing redirect rules (and maybe their type etc).

I have not been able to find this feature in the existing solution. Is this possible? Or could it be a future feature?

Best regards

"Stop processing of subsequent rules" for Rewrite not working

Version 1.8.2 - freshly installed on Sitecore 8.2.
<rule name="RuleForH" stopProcessing="true"> <match url="^practices/(h[_0-9a-z-\%]+)" /> <action type="Rewrite" url="practices/h/{R:1}" /> </rule> <rule name="RuleForHREdirect" stopProcessing="false"> <match url="^practices/h/([_0-9a-z-\%]+)" /> <action type="Redirect" url="practices/{R:1}" /> </rule>
Those two rules are working properly while set up directly in ISS but don't work from Sitecore module.
They are behaving like "Stop processing of subsequent rules" is not working at all and going into infinite loop.

Nightly Cache clear breaks redirects

In our Sitecore environment (version 7.2), we have one CMS server, and two CD servers (one for QA and one for Production) with two web servers for each environment. When I create the redirects and publish them to their respective targets, they work perfectly fine.

The issue arises when it looks like the Sitecore cache is clearing each night. On the CMS server's URL Rewrite logs, it looks like it is adding the redirects to the cache, and when I go to the cache admin screen, I can see that the cache looks like it has been built properly. When I look at the web server's URL rewrite logs, the redirects are not being added to the cache.

The following things will allow the redirects to start working again:

  1. Unpublishing and republishing the redirects to the CD servers.
  2. Restarting the site in IIS
  3. Recycling the App Pool for the website

After unpublishing and republishing the redirects, I can go to the web server's URL Rewrite logs and see the inbound rules being refreshed in the cache.

Any idea what could be going on and how I can fix this?

Sitecore 9 Support

When Url Rewrite is installed in a sitecore 9 system I get the following error:

Source: Hi.UrlRewrite
   at Hi.UrlRewrite.Caching.RulesCache.SetRules[T](IEnumerable`1 outboundRules, String key)
   at Hi.UrlRewrite.Caching.RulesCache.SetInboundRules(IEnumerable`1 inboundRules) in C:\git\UrlRewrite\Hi.UrlRewrite\Caching\RulesCache.cs:line 31
   at Hi.UrlRewrite.Processing.RulesEngine.GetCachedInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 254
   at Hi.UrlRewrite.Processing.InboundRuleInitializer.Process(PipelineArgs args) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRuleInitializer.cs:line 30

and

PID[8108] Error       2088 20:15:50 ERROR UrlRewrite[web]::Exception occured
Exception: System.MissingMethodException
Message: Method not found: 'System.Object Sitecore.Caching.CustomCache.GetObject(System.Object)'.
Source: Hi.UrlRewrite
   at Hi.UrlRewrite.Caching.RulesCache.GetRules[T](String key)
   at Hi.UrlRewrite.Caching.RulesCache.GetInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Caching\RulesCache.cs:line 26
   at Hi.UrlRewrite.Processing.InboundRewriteProcessor.GetInboundRules(Database db) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 82
   at Hi.UrlRewrite.Processing.InboundRewriteProcessor.ProcessUri(Uri requestUri, Database db, InboundRewriter urlRewriter) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 69
   at Hi.UrlRewrite.Processing.InboundRewriteProcessor.Process(HttpRequestArgs args) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 36

This appears to be similar to #28 and leads me to believe that sitecore regularly changes their caching model.

Do you have any plans to support Sitecore 9 with this module?

Rewrite under Inbound Rule isn't updating SC 7.5

I have an Inbound Rule with a Rewrite child, and updating/saving the rewrite has no effect. If I update, then duplicate the item, and have the Inbound Rule use the new duplicated item, my changes show up.

Sitecore 7.5
Rewrite Module 1.7.2

Sitecore 9.3 error on install

hello,
I get this error on installing on Sitecore 9.3:
Method not found: 'System.Web.HttpContext Sitecore.Pipelines.HttpRequest.HttpRequestArgs.get_Context()'.
Can you please advice?
Thanks

Could we make the "Simple Redirects" within Sitecore always use 301 Redirect statuscode?

Could we make the "Simple Redirects" within Sitecore always use 301 Redirect statuscode? How much effort would that take? I tested one of the redirects I had already set up for one of the website, and it is using a 301 AND 302 redirect, for some reason. We really want all of them to just use 301 redirects.

We know that Inbound rules provide this functionality. But the inbound rules are much more complicated than I think they need to be, with multiple steps to get up one redirect (i.e. set up the Pattern Match, then the Redirect). Also, most of the time, we won't want to be setting up a Pattern Match, but a specific exact match. The pattern matching admin screen is pretty confusing and overwhelming for the average content author. I want them to just be able to set up the Simple Redirects and have it use a 301 redirect.

Unable to initialize the module

After installing the component following exceptions are getting logged.

7812 06:45:12 INFO Initializing URL Rewrite.
7812 06:45:39 INFO UrlRewrite[core]::Adding 0 rules to Cache [core]
7812 06:46:08 ERROR UrlRewrite::Exception during initialization.
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: innerField
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Data.Fields.CustomField..ctor(Field innerField)
at Hi.UrlRewrite.Templates.Folders.RedirectFolderItem.get_SiteNameRestriction() in C:\git\UrlRewrite\Hi.UrlRewrite\Templates\Folders\RedirectFolderItem.cs:line 51
at Hi.UrlRewrite.Processing.RulesEngine.GetSiteNameRestriction(RedirectFolderItem redirectFolder) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 221
at Hi.UrlRewrite.Processing.RulesEngine.CreateInboundRuleFromSimpleRedirectItem(SimpleRedirectItem simpleRedirectItem, RedirectFolderItem redirectFolderItem) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 165
at Hi.UrlRewrite.Processing.RulesEngine.GetInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 82
at Hi.UrlRewrite.Processing.RulesEngine.GetCachedInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 254
at Hi.UrlRewrite.Processing.InboundRuleInitializer.Process(PipelineArgs args) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRuleInitializer.cs:line 30

4908 07:18:53 ERROR UrlRewrite[web]::Exception occured when saving item after save - Item ID: {540C3ED4-E14C-4A34-9AFB-5F3C7251CBE0} Item Path: /sitecore/content/Sample Rewrites/Simple Internal Redirect
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: innerField
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Data.Fields.CustomField..ctor(Field innerField)
at Hi.UrlRewrite.Templates.Folders.RedirectFolderItem.get_SiteNameRestriction() in C:\git\UrlRewrite\Hi.UrlRewrite\Templates\Folders\RedirectFolderItem.cs:line 51
at Hi.UrlRewrite.Processing.RulesEngine.GetSiteNameRestriction(RedirectFolderItem redirectFolder) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 221
at Hi.UrlRewrite.Processing.RulesEngine.CreateInboundRuleFromSimpleRedirectItem(SimpleRedirectItem simpleRedirectItem, RedirectFolderItem redirectFolderItem) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 165
at Hi.UrlRewrite.Processing.RulesEngine.GetInboundRules() in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 82
at Hi.UrlRewrite.Processing.RulesEngine.UpdateRulesCache(Item item, Item redirectFolderItem, Action`3 action) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 309
at Hi.UrlRewrite.Processing.RulesEngine.RefreshRule(Item item, Item redirectFolderItem) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RulesEngine.cs:line 292
at Hi.UrlRewrite.Processing.UrlRewriteItemEventHandler.RunItemSaved(Item item, ItemChanges itemChanges) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\UrlRewriteItemEventHandler.cs:line 82

Configuring URL Rewriter on CD sitecore 9.1

Hello,

I upgraded from Sitecore 8.2 update 6 to sitecore 9.1.. and I updated the files for the url rewriter on both CM and CD. I can see that it is working fine on CM, but not on CD.. Is there anything that I should check to see if it is missing or needs updating?

I keep getting this in the CD log:
4356 03:00:23 INFO UrlRewrite[web]::Adding 0 rules to Cache [web]
4356 03:00:29 INFO UrlRewrite[pub]::Adding 0 rules to Cache [pub]

Although it should be 1310 rules..

Anything I should look into?
Thanks,

How to use this module in a multi site (multi domain) setup?

We are running SXP 9.0.1 PaaS with multiple sites setup in the same solution. with three different domains.

The module has been installed and it was running fine, we were able to create different types of redirects.

However we realised if you have a redirect setup within the solution it's basically affecting other sites as well, which we don't want to happen.

Is there a way to make the redirects site specific?

Have To Clear Cache After Creating New Redirect

I am running Sitecore 8.0, Update 4.

After creating a new Simple Redirect it does not work -- until I manually go in and clear the cache via sitecore/admin/cache.aspx

After clearing the cache it works fine.

Shouldn't this be handled automatically by the module?

Query String in Simple Redirect

Hi Andy,
Is there a way to append query string while using internal link in Simple Redirect ?
It works fine when I use an external link but when query string is provided while configuring an internal link, it redirects to the link without the query string.

Making domain-level redirects happen after specific page redirects

Hello, I'm looking to use this module to replace some Web.config rewrite rules.

Our site admins would like to create redirects in the admin without having to have us make code changes.
It seems we can't mix Web.config rewrites with sitecore-based redirects because it's unpredictable.
The Web.config rewrites happen first and sometimes make the sitecore-based rewrite rules not match.

We have many domains pointing to our one Sitecore instance.
Example: "bar.org" (primary site) and "foo.org" (additional domain)

We have two types of rules (using rewrite maps because there are tons of these), shown below.

I know I can handle both of these redirect types with this module, but is there anything I can do to make sure the domain level redirects happen last (after the page-level redirects have had a chance to match)?

Page Level:

    <rule name="Foo rule" stopProcessing="true">
        <match url=".*"/>
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(www.)?foo.org$"/>
            <add input="{FOO:{URL}}" pattern="(.+)"/>
        </conditions>
        <action type="Redirect" url="{C:1}" appendQueryString="true" redirectType="Permanent"/>
    </rule>
    ...
    <rewriteMap name="FOO">
        <!-- foo.org -->
        <add key="/my/page/here" value="https://www.bar.org/some/other/specific/path"/>
        ... more here ...
    </rewriteMap>

Domain Level:

    <rule name="Domain-level rule" stopProcessing="true">
        <match url=".*"/>
        <conditions trackAllCaptures="true">
            <add input="{Domains:{HTTP_HOST}}" pattern="(.+)"/>
            <add input="{REQUEST_URI}" pattern="(.+)"/>
        </conditions>
        <action type="Redirect" url="{C:1}{C:2}" appendQueryString="false" redirectType="Permanent"/>
    </rule>
    ...
    <rewriteMap name="Domains">
        <add key="foo.org" value="https://www.bar.org/foo"/>
        ... more here ...
    </rewriteMap>

Error in log every time I hit a redirect

This is in a clean instance of Sitecore 8.1 U1 with URL Rewrite 1.8 installed. I copied the sample set into my home directory, then set the website dropdown to my website. I then tried to hit "external1" from the simple redirect, but every time, I get the error below. Locally, it's also like everything just stopped working, so I'm trying to figure out why this might be. Thanks.

7204 21:00:20 ERROR UrlRewrite[web]::Exception occured
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Hi.UrlRewrite
at Hi.UrlRewrite.Processing.RewriteHelper.ReplaceBackReferences(Match match, String input, String backReferenceVariable) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\RewriteHelper.cs:line 30
at Hi.UrlRewrite.Processing.RewriteHelper.ReplaceConditionBackReferences(Match conditionMatch, String input) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\RewriteHelper.cs:line 19
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRedirectAction(InboundRule inboundRule, Uri uri, Match inboundRuleMatch, Match lastConditionMatch, InboundRuleResult ruleResult) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 417
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRegularExpressionInboundRule(Uri originalUri, InboundRule inboundRule) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 270
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessInboundRule(Uri originalUri, InboundRule inboundRule) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 204
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRequestUrl(Uri requestUri, List`1 inboundRules) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 59
at Hi.UrlRewrite.Processing.InboundRewriteProcessor.ProcessUri(Uri requestUri, Database db, InboundRewriter urlRewriter) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 76
at Hi.UrlRewrite.Processing.InboundRewriteProcessor.Process(HttpRequestArgs args) in c:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 36

Deleted redirects cause exceptions when rebuilding reporting db or aggregating interactions

I'm working with a customer using version 1.8.1.3 of the module. They are unable to rebuild their reporting database because the interactions contain activity with redirects that have been deleted. Instead, they receive this exception:

6708 2017:06:06 11:03:51 ERROR Aggregation Error
Exception: System.Exception
Message: Object reference not set to an instance of an object.
Source: Sitecore.ExperienceAnalytics
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.ProcessSegments(AggregationPipelineArgs args, IEnumerable`1 segments)
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.OnProcess(AggregationPipelineArgs args)
   at Sitecore.Analytics.Aggregation.Pipeline.AggregationProcessor.Process(AggregationPipelineArgs args)

Nested Exception

Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Hi.UrlRewrite
   at Hi.UrlRewrite.Analytics.ByUrlRewriteRedirect.<ExtractDimensionKeys>d__2.MoveNext() in C:\git\UrlRewrite\Hi.UrlRewrite\Analytics\ByUrlRewriteRedirect.cs:line 27
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Sitecore.ExperienceAnalytics.Aggregation.Dimensions.PageEventDimensionBase.GetDimensionKeys(IVisitAggregationContext context)
   at Sitecore.ExperienceAnalytics.Aggregation.Dimensions.PageEventDimensionBase.<GetData>d__8.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at Sitecore.ExperienceAnalytics.Aggregation.Pipeline.SegmentProcessor.ProcessSegments(AggregationPipelineArgs args, IEnumerable`1 segments)

Steps to reproduce:
install fresh 8.1u3 instance
install url rewrite 1.8.1.3
deploy marketing definitions
smart publish site

in incognito window:

  • Browse to site homepage
  • browse to /external1 (redirected to sitecore.net)
  • browse to site homepage
  • browse to page to end tracking/abandon session

validate interaction logged to analytic db via robomongo
Open content editor
delete simple external redirect item
smart publish site

attach secondary reporting database
create new connection string for reporting.secondary
rebuild reporting database (/sitecore/admin/rebuildreportingdb.aspx)

Expected Behavior
Application does not process redirects for items now missing

Actual Behavior
Sitecore halts processing interactions, cannot rebuild analytics db.

We were able to work around this problem by checking for a null item when grabbing the pageEvent from Sitecore. I will submit a pull request shortly with the code we are using to work around the issue; I'm not sure this is how you would want to handle reporting or not, but it allowed us to get Experience Analytics working again.

Application Slow start due to init processor reading high latency web databases

Can't exactly say this is an issue, it could be a feature request as well.

Basically we have 2 web databases, one of them is in a GEO-distributed remote region which has 200 ms latency with the main CM instance.

We uses publishing service for publishing tasks since out of box publishing take 8+ hours to complete a site smart publish. But remote database definition is still added in CM for handling event queue.

We noticed after a while, CM takes around 15 mins to start up every time it restarts. With some profiling and traces, we identified the bit that takes most time and blocking all requests is the processor:
<processor type="Hi.UrlRewrite.Processing.InboundRuleInitializer, Hi.UrlRewrite" />

After removing this processor, CM startup time is back to normal.

In the code, it go through all the databases and caches the inbound rules. Remote web database is one of them.

Since this is authoring and looks like this is for Site visit, we assumes it should be fine to disable this processor on CM. We need more time to validate but not sure if anyone can confirm this?

Also not sure what's the best way to handle this properly going forward. What's your view?

Can we match url with request uri or other elements?

Hi,

I've just tried to match the bits of the url after the http_host but it doesnt seem to match.

I've using the advanced condition and used condition input string {REQUEST_URI} to match. However, it doesnt seem to work. Is there any way for this to work?

Thanks in advance,

Neel

Error when redirecting

I'm seeing this error in UrlRewrite log. Please help, site needs to go live in 10 days.
Sitecore 9.1.1
installed update package for 9
Thanks in advance,
Bill

7332 15:15:04 ERROR UrlRewrite[web]::Exception occured
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Hi.UrlRewrite
at Hi.UrlRewrite.Processing.RewriteHelper.ReplaceBackReferences(Match match, String input, String backReferenceVariable) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RewriteHelper.cs:line 30
at Hi.UrlRewrite.Processing.RewriteHelper.ReplaceConditionBackReferences(Match conditionMatch, String input) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\RewriteHelper.cs:line 19
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRedirectAction(InboundRule inboundRule, Uri uri, Match inboundRuleMatch, Match lastConditionMatch, InboundRuleResult ruleResult) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 420
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRegularExpressionInboundRule(Uri originalUri, InboundRule inboundRule) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 273
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessInboundRule(Uri originalUri, InboundRule inboundRule) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 207
at Hi.UrlRewrite.Processing.InboundRewriter.ProcessRequestUrl(Uri requestUri, List`1 inboundRules) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriter.cs:line 59
at Hi.UrlRewrite.Processing.InboundRewriteProcessor.ProcessUri(Uri requestUri, Database db, InboundRewriter urlRewriter) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 76
at Hi.UrlRewrite.Processing.InboundRewriteProcessor.Process(HttpRequestArgs args) in C:\git\UrlRewrite\Hi.UrlRewrite\Processing\InboundRewriteProcessor.cs:line 36

Can't find Redirect Folder after installing

Hello
I've installed the module on SiteCore 7.2
After installing this package, I cannot find the Redirect Folder in sitecore/templates/Modules/UrlRewrite/Templates/Redirect Folder.

Did I miss something?

Best regards

Track capture groups across conditions - Is this available ?

Hi Andy,

This is more of a question than an issue.

Is there an option to "Track capture groups across conditions" , as in how we use it in in IIS to maintain the back reference if multiple conditions are added. This maintains C:0, C:1 across conditions as you might be aware rather than overriding it.

image

Add an OSS license

Any chance you could add an OSS license (eg. MIT / Apache2) to the project? Unlicensed code is a bit tricky from a legal perspective, and many clients legal teams might take issue with it.

ERROR Page event definition UrlRewrite Redirect not found

I'm getting the following errors occurring constantly in our Sitecore servers even though the redirect entries do exist and do work.

000 10:43:04 ERROR Page event definition UrlRewrite Redirect not found, page URL /finance/contact/faq 9044 10:43:07 ERROR Page event definition UrlRewrite Redirect not found, page URL /main/hilux/prices 6492 10:43:08 ERROR Page event definition UrlRewrite Redirect not found, page URL /car-dealers/south-australia/eastwood-5063?gclsrc=ds&dclid=CNHBw82SitICFYN2YgodpmsK7A 8524 10:43:10 ERROR Page event definition UrlRewrite Redirect not found, page URL /hilux

Additionally I'm getting the following error in the URLRewrite log but this might be a seperate issue.

8024 09:27:41 ERROR UrlRewrite[live]::Exception occurred during tracking. Exception: System.NullReferenceException Message: Object reference not set to an instance of an object. Source: Hi.UrlRewrite at Hi.UrlRewrite.Analytics.Tracking.RegisterEventOnRedirect(ProcessInboundRulesResult results) in c:\git\UrlRewrite\Hi.UrlRewrite\Analytics\Tracking.cs:line 54

Is this an issue with the Sitecore redirect module or an issue with my sitecore instance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.