Try our conversational search powered by Generative AI!

SiteUrl for site with backend with different url.

Vote:
 

We have an upgraded load balanced site with 2 webfronts for visitors and a backend server where admin/editors logs in.
The site on the backend server has a different url than the webfronts and with the new way of configuring the SiteUrl in the database we have no way of configuring one SiteUrl for the backed site and another url for the front sites.

So everywhere we use SiteUrl in the code we get the "wrong" url on the backend site.

Adding both urls as hosts does not help.

Any help on how we can approach this problem is appriciated.

Do we have to make our own setting for this and use that instead of the build in SiteUrl property?

#85272
Apr 22, 2014 8:50
Vote:
 

Have you tried setting attribute uiUrl on appicationSettings element? You can set it to an absolute Uri like "http://myedithost/EPiServer/CMS/"

#85275
Apr 22, 2014 9:24
Vote:
 

That does not help unfortunality.

A little more information about the problem:

The public front servers have the url www.mysite.se which is specified as siteurl.
The backend site has edit.mysite.se as url.

In the code where SiteDefinition.Current.SiteUrl is used for example to build links we always get the front url www.mysite.com so when browsing the edit site you sometimes click on a link that leads you to the front site when it shouldn't.

In CMS6R2 this was not a problem since you defined SiteUrl in the config files and could have different urls on sites that uses the same database.

Of course we can rewrite the code everywhere SiteUrl is used but I hope we won't have to...

 

#85280
Apr 22, 2014 11:34
Vote:
 

We are facing a similiar problem now. In our case we've pre 7.5 been sharing the database between staging and prod instances of the same EPi-application.

Is there a way inherit and tweak SiteDefinition.Current.SiteUrl?

#114324
Dec 10, 2014 10:12
Vote:
 

You can have several hosts for the same site (even several hosts mapped to same language). And when generating outgoing links it shoule not output absolute urls (with hosts) as long as the linked content is on the same site and language. Meaning when you click on a link you should stay on the same host.

Is there a apecific case where you get into problem so that it redirects from one host to another where it should not?

#114330
Dec 10, 2014 11:15
Vote:
 

When switching language in the Sites Tab.

#114332
Edited, Dec 10, 2014 11:29
Vote:
 

I see, our recommendation is to not share the database between production and staging/testing etc. You could take a backup of the production db and then restore it and then change siteurl on the restored db. Something like:

BACKUP DATABASE [EPiServerDB_926958a7] TO DISK = N'c:\temp\epicms_alloy.bak'  
WITH NAME = N'Alloy-Full Database Backup'
GO

-- To get logical names from a backup use below statement, in my case it returns 'Database1'
--RESTORE FILELISTONLY FROM DISK = N'c:\temp\epicms_alloy.bak'

RESTORE DATABASE EPiServerDB_926958a7_new
FROM DISK = N'c:\temp\epicms_alloy.bak'
WITH
MOVE N'Database1' TO N'c:\temp\sql\epicms_alloy.MDF',  
MOVE N'Database1_LOG' TO N'c:\temp\sql\epicms_alloy_LOG.LDF'
GO

USE [EPiServerDB_926958a7_new]
GO

--Here I assume that there is only one site, otherwise Where statements can be used
UPDATE [dbo].[VW_EPiServer.Web.SiteDefinition]
   SET [SiteUrl] = 'http://testenvironment/'
GO

UPDATE [dbo].[VW_EPiServer.Web.HostDefinition]
	SET [Name] = 'testenvironment'
	WHERE [Name] = 'localhost:56979'
GO

I will add a techstory to our backlog to see if we can make it pluggable someway to change the SiteUrl.

#114333
Dec 10, 2014 11:37
Vote:
 

We have the problem because edit/admin site has a different url than webfronts so not sharing db is not an option for us.

We solved it with a rewriter rule on the edit/admin server.

#114334
Dec 10, 2014 11:41
Ted
Vote:
 

I think the scenario described by Kristoffer is a common one: public web front servers have a URL like www.mysite.com.

The CMS machines are behind firewalls and are accessed with URLs like https://edit.mysite.com or https://someservername

However, because edit machines and web front servers share the same database, the site URL setting must be set to the public host name.

Whenever a web edit switches sites, for example, in the edit UI, they end up on the public host name (where, if correctly set up, the edit mode doesn't exist).

I guess a rewrite rule, as Kristoffer suggested, is an acceptable workaround. But I think this scenario should be supported natively through site settings?

#118761
Mar 13, 2015 10:20
Vote:
 

I agree with Ted and am just about to set up a solution just like that where the edit/admin interface are on a special server.

Thanks for the heads up that I need to do a workaround

#118762
Mar 13, 2015 10:39
Vote:
 

The scenario where you have for example 2 webfronts and 1 edit server does not require a rewrite.

In order to make sure that the URL in Edit mode is never the URL to the public site simply do this:

Under "Manage Websites" -> "Edit Website"

Change URL (General->URL) to the url to the edit server (edit.site.com) 

Then add one hostname to site.com with the culture you want and no type.

Then add another hostname to edit.site.com with the culture you want and no type.

The public URL for the webfronts will still work (site.com), but edit mode will always use edit.site.com, even when switching between sites.

#140417
Oct 19, 2015 17:11
Vote:
 

We also have a project with one edit server and 2 front end serveres. No need for any rewrite rule. Do as Tommy says. That works.

#140427
Oct 19, 2015 23:48
Vote:
 

@Johan Björnfot:

"You can have several hosts for the same site (even several hosts mapped to same language). And when generating outgoing links it shoule not output absolute urls (with hosts) as long as the linked content is on the same site and language. Meaning when you click on a link you should stay on the same host.

Is there a apecific case where you get into problem so that it redirects from one host to another where it should not?"

This works fine when the URLs you are producing are for the actual site. But if you want to send an e-mail you will need to produce an absolute URL. Using the workaround I decribe above SiteUrl will point to the adminserver and therefor not work for visitors.

It would be great if the SiteUrl could be configured on a per server basis. But as it currently can not I had to simply use the following instead of SiteUrl:

HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
#140504
Oct 21, 2015 14:49
Vote:
 

There is also the case where a site is set to respond to a origin-hostname used by a CDN. You never want to output the origin-hostname anywhere.

A flag for "official hostname (for language)" or something would be valuable in this instance.

#140505
Oct 21, 2015 15:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.