Vhost, redirected to admin

Enonic version: 6.6.2
OS: Ubuntu

Hi I follwed the guide for setting up Enonic as a service.

But I am struggling with the vhost. When hitting my domain http://mysite.se
I get directed to http://www.mysite.se/admin/tool.

If I hit these directly they work.


I tried to read the logs but it just says Enonic started up prefectly. Any Ideas?

my vhost:

enabled = true

mapping.a.host = mysite.se
mapping.a.source = /
mapping.a.target = /portal/master/mysite
mapping.a.userStore = system

mapping.admin.host = mysite.se
mapping.admin.source = /admin
mapping.admin.target = /admin
mapping.admin.userStore = system

It seems there is a redirection from “mysite.se” to “www.mysite.se”

I would change the mapping host lines to:

  • mapping.a.host = www.mysite.se
  • mapping.admin.host = www.mysite.se

Tried you suggestion but same thing happens.

This works as I want localy

enabled = true

mapping.a.host = localhost
mapping.a.source = /
mapping.a.target = /portal/master/mysite

mapping.admin.host = localhost
mapping.admin.source = /admin
mapping.admin.target = /admin
mapping.admin.userStore = system

Hmm, initially The setup looks good, but where does the www. part come from? Are you running apache in front - or is the site doing some kind of redirection?

No, running on Amazon web services. EC2 instance with an ‘A’-record(Route 53).

A-record: mysite.se
CNAME: www.mysite.se

Using iptables if it could have somtething to do with that?
edit: uninstalling ip-tables and testing at port 8080 made no difference.

There are several strange things happening here, lets test something:

With this vhost

mapping.a.host = mysite.se
mapping.a.source = /
mapping.a.target = /portal/master/mysite
mapping.a.userStore = system

The following url http://mysite.se/portal/master/mysite should then give you the errorpage for the target site, as the actual path queried will be /portal/master/mysite/portal/master/mysite.

Please test this both with and without the “admin” record (to see if something is different when it is removed).

Removing the admin part makes no difference. Actually its my-site instead og mysite if it makes any difference.
Whit the config hitting http://my-site.se/portal/master/my-site takes me to the my real site and not the error page.

mapping.a.host = my-site.se
mapping.a.source = /
mapping.a.target = /portal/master/my-site
mapping.a.userStore = system

mapping.admin.host = my-site.se
mapping.admin.source = /admin
mapping.admin.target = /admin
mapping.admin.userStore = system

Hmm… is this a dummy domain or an actual domain? my-site.se actually exists… I was assuming this was a test-domain. Maybe you can share the settings of your /etc/hosts file?

I made up the name “my-site”. The point is it has a “-” in the name.

I did not touch /etc/hosts but it looks like this localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

If it would help the actual site is ankis-bar.se

Good morning,

So if you are able to access without error to “mysite.se/portal/master/mysite” or that you are redirected from “mysite.se/” to “mysite.se/admin/tool” it is because the virtual host mapping is not set as you guessed.

I will list below some causes that I think about:

1 - The line "enabled = true” has to be uncommented

2 - The mappings can be overridden if you used the same mapping name. Make sure it is not the case

mapping.a.host = mysite.se
mapping.a.source = /
mapping.a.target = /portal/master/mysite
mapping.a.userStore = system

mapping.a.host = myothersite.se
mapping.a.source = /
mapping.a.target = /portal/master/mysite
mapping.a.userStore = system

3 - The config files are not seen. Check the value of XP_HOME (It is printed when the server starts):
# Home directory

4 - The host is not the one you defined in the vhost mapping (Dashes in the name are not an issue):

In a controller like a service for example, try printing the host:
exports.get = function (req) {

1 Like

Thank you all for using time on this issue. Verified all but number 3 looks suspicious to me.

 $ echo $XP_HOME

In the log…
# Install directory is /opt/enonic/xp
# Home directory is /home/xp/enonic/xp

Thank you. Now it works.
As gri was suggesting. The vhost file I was editing was not the one where my XP_HOME was pointing.

Good to get this solved! But one question, where did you edit then? Is there anything we need to fix in The docs?

No I think you are fine. I just missed the part that /home/xp/enonic/xp/ is my new $XP_HOME and I have to edit the vhost in there. I was editing the vhost in /opt/enonic/...
sudo cp -R /opt/enonic/xp/home/* /home/xp/enonic/xp/
sudo chown -R xp:xp /home/xp/enonic