Sitecore - rewrite "on" - "in URLs, but still allow dashes as legal position names

I read half a dozen guides to rewrite spaces into something friendlier at Sitecore, but they all rely on the Sitecore <encodeNameReplacements/> element, which also cancels the replacement requiring "-" to be an illegal character for names.

The problem is that the URL of our application has a "-" in the host name. Sitecore overwrites this, resulting in 404.

Does anyone have any ideas on how to do this URL rewriting in Sitecore without relying on <encodeNameReplacements and still allowing a "-" as a character name symbol? Our current best idea is to use something more complex than a simple "-", such as a "-" or "_". This is not a good idea, so I will be grateful for any information that you guys have about this.

EDIT: We're launching the setup of multiple sites with Sitecore 6.5

+4
seo url-rewriting sitecore sitecore6
source share
2 answers

So, if I accept correctly, you want to replace the spaces in the element names with some other SEO-optimized character. No matter what configuration you configure, you need to apply the transformation on both sides of the equation (pun intended). Thus, "-" or "_" must become illegal characters for element names.

I generally think this is a bad idea for this, and would prefer my content editors to determine the exact URLs for their content.

But if you absolutely need to implement this, as a rule, one of the solutions is to implement a custom handler to change your real name of the element, leaving the display name of the element in its original form.

Hope this helps.

+2
source share

What version and build of Sitecore are you using?

I just looked at Sitecore.Links.LinkProvider in Sitecore.Kernel , and the BuildItemUrl method replaces the encodeNameReplacements characters with part of the URL path, so it must leave its hostname on its own.

I would expect the same thing to happen and vice versa, and by looking at Sitecore.Pipelines.HttpRequest.SiteResolver , the SiteContext will be resolved by matching the requested Uri to specific sites. Next, the Sitecore.Pipelines.HttpRequest.ItemResolver process decodes Item Url, but the site has already been resolved at this point.

hostName you set the hostName attribute for <site> elements? Have you tried setting the targetHostName attribute? You tried to set multiple host names, I do not expect it to work with spaces, but it is worth a try if you are telling the truth:

 <site name="website" hostName="my-site.com|my site.com" ... /> 

I tried to replicate your problem on my local computer, but it worked as expected for me ... If you are not working with very strange character sets, this, in my opinion, is still the best way to encode names.

+2
source share

All Articles