Sitecore 10.1 | Site resolving works only if I check "Enable Preview" site property (for items referenced from different site) - sitecore

I have multiple sites architecture. Like this one
sitecore/content/site1
sitecore/content/site2
For each item of site2 referenced in site1 I get the following URL:
www.site1.com/sitecore/content/site2/item
instead of
www.site2.com/item
I've debugged Sitecore.Sites.DefaultItemSiteResolver and found, that the site can be only resolved only if it has "Enable Preview" site property set to true:
But now, after setting it to true, I have another problem, the page resolving now works also in the preview (which is not the desired behavior, I want only the "webiste" site to be resolved there). It even ignores the "Preview.ResolveSite" setting, which is set to false.
What am I doing wrong? How to enable site resolving for published sites but not for the preview?

There are several settings in Sitecore.config that help to configure proper site resolving logic in multisite Sitecore solutions:
Rendering.SiteResolving — enables site resolving, so cross-site links can be rendered with correct hostname, language, and virtual folder.
Rendering.SiteResolvingMatchCurrentSite — item location is taken into consideration when a cross-site link is built. All items under a certain site root will be resolved in the context of that root.
Rendering.SiteResolvingMatchCurrentLanguage — when true, context language is taken into consideration when a cross-site link is built.
It is recommended to keep the Rendering.SiteResolving setting value at true for any multisite solution in order to ensure that cross-site links are built with the correct parameters. In this case, the Experience Editor and Preview mode are opened in the context of the site defined in the Preview.DefaultSite setting, if no other site can be resolved.
To make sure that items are opened in context of correct site, you must set the Rendering.SiteResolvingMatchCurrentSite setting to true.

Related

Sitecore Homepage Shows Error Message, but is viewable at different URL

In my sitecore instance, (8.2 rev 170407), I'm having an issue viewing the homepage in both my dev enviroment and my staging server. Going to the homepage (the root of the server) redirects to this URL
http://[website]/sitecore/service/nolayout.aspx?item=%2f&layout=%7b00000000-0000-0000-0000-000000000000%7d&device=Default
The message says:
The resource you are looking for (or one of its dependencies) may have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Additional Information:
Requested URL: /
Requested Layout: {00000000-0000-0000-0000-000000000000}
Requested Device: Default
In testing this, I set the Home item to have an alias of /home, which I can visit and see the page looking fine.
This issue began when I set up Helix via the Yeoman script, and built it in VS2015. This is my first Sitecore Site so I handily accept that I made a mistake -- for example when I built the Solution for the first time it overwrote my Web.config. I had a backup of that Web.config and was able to bring the site back online but the Homepage has eluded me.
I've published, and republished. In my naive experience, I find it odd I can see the homepage at /home but not /. Any advice is appreciated, thanks.

Sitecore Alias refuses to work

I've inherited a Sitecore project and added a new alias to a set of existing aliases on an item within the content tree.
However, although I can visit the older aliases any of my new aliases seem not to work and lead to a 404.
I've tried publishing the content items and even System/Aliases however they still refuse to work.
Am I missing something obvious?
Several things could be preventing your aliases from working, some of which depend on the setup of your system:
Verify that your aliases were published. To do this, switch over to your Web DB and check to see if the aliases that you configured appear, as expected. If they are not published, be sure to run a publish on the Aliases folder (I suggest a Republish, just to be safe).
If after that your aliases are not working and are still not published, try running a full site Republish.
If they still won't publish, move on to number 3, below
If your aliases your aliases are not working and are published, try rebuilding the Link Database.
If your aliases are still not working, move on to numbers 2 and 4, below
Ensure that each alias that you defined is unique. Note that for a multi-site solution, being unique for the context site is not enough - if you have the alias defined for one of the sites and try to define it for the other it will not work - as the alias cannot be used differently for each site.
Note that this is the default behavior of Sitecore's AliasResolver
If necessary, you can customize the AliasResolver to allow you to specify a separate alias folder for each site, following this tutorial by Yogesh Patel.
(skip this if you completed step 1 and were able to publish your aliases successfully) Special Access Rights/Permissions are required in order to configure Sitecore aliases. I highly doubt that this is the issue, as you were clearly able to create alias items, but I am a fan of covering the base-cases first, so I would verify all the same.
If you do find that you are missing the necessary permissions and are trying to figure out how to configure them/if you have trouble finding what permissions you need then you should take a look at this article, by John West.
Also unlikely, but possible, is that redirects/rewrites were configured to send you to the 404 page from the URLs you set as aliases (it could be a RegEx that redirects all of the URLs that you tried to provide as aliases). Start by checking out your config files and/or IIS for Rewrites and Redirects. If you do not see anything, then check for redirects.
If redirects are your issue, then the Redirect Module is likely to be the culprit. Check if it is installed and configured to redirect your aliases to 404 pages
If the Redirect Module is not configured, check for custom redirection in your code
Hopefully this helps. Good luck and happy coding! :)
After checking the points raised by Zachary Kniebel I finally figured it was down to the scope of the items and how URL are generated.
For example we have:
Home/
Holidays/
Some Item
Now the alias could be Toads on Some Item. So I assumed the following URL would work:
http://www.example.com/holidays/some-item
http://www.example.com/holidays/toads
However, because aliases are system wide it dawned on me that really the alias was:
http://www.example.com/toads
This means in order to get the structure I wanted I had to create the alias Holidays/Toads instead of just Toads, replicating the tree structure as needed.
When I did this the aliases started working as expected.

SIteCore - multisite - displaying page from wrong site

We have a multisite SiteCore setup with 2 sites within the same .Net solution.
This works by setting the rootPath property on a Site Definition in web.config to limit the site to part of the SiteCore folder structure.
This works well apart from when pages are created with the same name as in the other site then it's serving content from the other site! We have inherited a fair bit of custom code in this solution form the other site so this may be the cause but dont know what Im looking for ...
Thanks
How are you referencing the sites? Do they each have their own host name? Do you have the "hostName" property set for the site node in the Site Defintion?
I will assume that you are not referring to them this way and instead, the sites are using the "virtualFolder" property. If both sites have the same default value of "/" for virtualFolder, attempting to get to either site will result in Sitecore rendering the first site that it matches on, which would be the site listed first.
Try putting the actual site name for "virtualFolder" and "physicalFolder" (e.g. "Site1" and "Site2", respectively). Then you can address your sites as http://yourserver.com/Site1 and http://yourserver.com/Site2. The "virtualFolder" will match first and render the correct site.
See Configuring Sites in the web.config File on SDN for additional information.
Hope this helps.
It turns out this is happening in this case because of a System alias that is redirecting for a subset of pages

Can't Open Web forms for marketers Form Designer or Security Manager

I have had WFFM running on a Sitecore instance for a while, but it has recently stopped working. When I go to "Form Designer" on an existing form, I get the standard Sitecore "The requested document was not found" page.
Requested URL: /applications/modules/web
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
Note that the requested URL is stated as /applications/modules/web instead of /applications/modules/web forms for marketers.
A lot of development has occurred on this site recently, so I'm not sure when exactly this started happening.
Additional: info:
Folder and file permissions are correct.
I've tried reinstalling the WFFM package, and made sure that all the files are in place.
Several processors have been added to the HttpBeginRequest pipeline, but I removed them all to test if they were the cause - they weren't.
I haven't upgraded Sitecore since WFFM was working and the version is correct.
No errors are logged
EDIT
This also seems to be affecting the Sitecore Security Editor:
Requested URL: /appl
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
EDIT 2
Further investigation with this is making me think it is related to the Requested URL. I originally thought the the "Not found" page was displaying the requested url incorrectly. However, if I attempt to goto mysite.com/sitecore/shell/applications/fake folder with spaces/fake page with spaces I get this error message:
Requested URL: /applications/fake folder with spaces/fake page with
spaces
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
As you can see the Requested Url is correct in the error message. So in relation to my problem, I think maybe Sitecore is requesting the wrong URL in the first place.
Additionally if I go to the go the following url by typing directly into the browser, then the Security Editor opens as expected:
mysite.com/sitecore/shell/Applications/Security/User-Editor
This is quite old now but I thought I'd provide an update for anyone else who encounters the problem.
Unfortunately, Sitecore support weren't able to help beyond pointing out that setting the addAspxExtension attribute to 'true' in the link provider seemed to solve the problem. This may have been acceptable except that extensionless URLs were important to the customer.
In the end I had to amend my link provider so that addAspxExtension is set to 'true' in the web config, and then I set it to false inside the GetItemUrl method for specified sites only.
So now whenever the context site is 'Shell' or 'Admin' etc, the extensions are added by default, but switched off in my main website.
Of course, this is a work around. I still don't know how to actually fix the problem
So the first thing that I am going to tell you is that I suspect that there is something wrong with your site declaration for Sitecore Modules. In your web.config, there's a site declaration for "modules_shell" and "modules_website". Those are where the code files that run the modules are usually located... a shell folder to run the parts that run in the Sitecore shell and a web folder to run the part that is accessed by the externally facing site. Please check your site declarations (and the form.config file) to make sure that you're not in live mode or something like that. I would definitely say that this is where you should start looking.
The next thing is to say that your comments about Sitecore not serving a url in the /sitecore/shell directory is really not surprising. Sitecore processes all requests unless you specifically tell it to ignore requests (like setting it in the IgnoreUrlPrefixes in web.config), it's going to try processing it. Like going to /sitecore/shell/applications gives me a layout error because it doesn't have anything set to handle that request. Now your error suggests that there is something wrong with Site declarations.. however, even if they were all right, it still wouldn't work.

Multilingual sites in Sitecore

I'am new to Sitecore and had few questions on Multilingual sites in Sitecore
First I added the new language to the existing site and try to access the same with sc* parameter for testing purpose.
The site throws "Input string is in incorrect format" error. Though the content is not added for this it should be a blank page, not sure why it's throwing the error.
If, by chance, your Sitecore instance has multiple sites (i.e. you're using the SiteDefinition.config file to define separate site host headers) then you need to specify the language per-site, in the language attribute within the particular site node in SiteDefinition.config.
The value would be the language code, like "en-US" or "da-DK" for instance. For reference, see this (this references the web.config, but it applies to SiteDefinition.config as well).
besides the sc_lang query parameter, you can also give the language in the url.
for example /en leads to English homepage, /nl-NL to the dutch homepage. the first part of the url is the language.
so /en/page1.asp leads to the en version of the page1 item under your home.
The current language is stored in a cookie check the website#lang cookie.. Where website is the name of the website.
The default language is located in the web.config or include files
With the LinkManager in the web.config you can configer the appearance