Foren

How to change the default access URL pattern? such as /group, /web/...

Zhenlei Li, geändert vor 7 Jahren.

How to change the default access URL pattern? such as /group, /web/...

Junior Member Beiträge: 51 Beitrittsdatum: 13.07.14 Neueste Beiträge
Hi List,
I am still working on Liferay v6.2, and built a portal 2 years ago with URL pattern as default, which public friendly url like http://myhostname/web/guest/xxxx;
secured friendly url like http://myhostname/group/guest/xxxxx.

Now I need to build 2nd portal with same domain name, I want to configure the new portal url pattern as:
public friendly url like http://myhostname/web2/guest/xxxx; secured friendly url like http://myhostname/group2/guest/xxxxx
I knew that I can chang 2nd level url /web/guest to /web/other/... but it's not good enough, because Control panel url still same.
How can change it? thank you all.

PS: I read the old thread in this forum https://web.liferay.com/zh/community/forums/-/message_boards/message/447746 and
https://web.liferay.com/zh/web/jonathan.neal/blog/-/blogs/lose-ten-pounds-off-your-url?_ga=1.240121667.1110506455.1460012141 already.
my requirement is different with them.
I expect 2 portals published by 1 DNS name instead of 1 portal with more virtual URL.
especially, I want a way to access 2 portal's Control Panel module with same DNS name.

please advise.
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Zhenlei,

You can do what you are trying to do, but not the way you are trying to do it. First you need to understand the three url patterns.

1. /web is used to identify pages that are public (guest access is permitted)
2. /group is used to identify private pages (you have to be authenticated to access them)
3. /user is used to identify a private (user) site.

These can be reconfigured if you don;t like the names using these properties --

    #
    # Set the private group, private user, and public servlet mapping for
    # com.liferay.portal.servlet.FriendlyURLServlet. This value must match the
    # servlet mapping set in web.xml.
    #
    # For example, if the private group pages are mapped to "/group" and the
    # group's friendly URL is set to "/guest" and the layout's friendly URL is
    # set to "/company/community", then the friendly URL for the page will be
    # http://www.liferay.com/group/guest/company/community. Private group pages
    # map to a site's private pages and are only available to authenticated
    # users with the proper permissions.
    #
    # For example, if the public pages are mapped to "/web" and the group or
    # user's friendly URL is set to "/guest" and the layout's friendly URL is
    # set to "/company/community", then the friendly URL for the page will be
    # http://www.liferay.com/web/guest/company/community. Public pages are
    # available to unauthenticated users.
    #
    # The friendly URL's for users, groups, and layouts can be set during
    # runtime.
    #
    layout.friendly.url.private.group.servlet.mapping=/group
    layout.friendly.url.private.user.servlet.mapping=/user
    layout.friendly.url.public.servlet.mapping=/web


The important thing to note here is that there is a servlet filter for each of these patterns. So you can't just use /web2/guest -- not without an additional filter. But if you are planning to use virtual host settings (as specified in the link you posted) then you don't care what the filters are mapping to. So right now you have /web/guest because that is the default. If you add your new site (under the same portal instance, or domain), and assuming that site is named acme, then you end up accessing the public pages using /web/acme and the private pages using /group/acme. You can then use the virtual host settings to dropm the /web so that you can access it using http://www.somehost.com/acme.

Now, in terms of the control panel, there is no separate control panel for each site, portal instance. The Control Panel is itself in fact a site. If you look closely at the URL you will see that there is a parameter that is used to perform "impersonation" of a site. So you access the control panel but you do so under the disguise of another site in the system. The parameter is doAsGroupId where the value equals the groupId (site id) for the site you are editing. If I have access to the "guest" site, and you have access to the "guest" and "acme" site, then you are able to access both sites via the control panel where as I cannot. If I try to access the control panel using the acme group id I will get an error.

Let me know if that helps clear things up.
Zhenlei Li, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Junior Member Beiträge: 51 Beitrittsdatum: 13.07.14 Neueste Beiträge
Andrew, thank you for the reply!
I am even clear on my goal that -- I want to replace /web and /group by /web2 and /group2.
According to your words ---"So you can't just use /web2/guest -- not without an additional filter.", yes you are right! I cannot made it by adding layout.friendly.url.private.group.servlet.mapping=/group2 in portal-ext.properties
or editing /webapps/ROOT/WEB-INF/web.xml . It will crash the portal.

I am very interesting on what's the additional filter I need? can you give some guideline? shall I overwrite some classes in com.liferay.portal.* package?

Thank you again
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Zhenlei,

Crash the portal? Really? I have done it many times before -- usually for the private mapping as most clients prefer a term other than group (like /private or /member, etc). As you mentioned, you have to change it in the portal-ext and in the ROOT/WEB-INF/web.xml though -- which sucks because when you upgrade (or in the case of EE apply patches) it overwrites the web.xml changes.

I have used this technique many times and it hasn't crashed my portal. If you are getting errors in the log, can you share them with us?

I guess I didn't understand your question -- I thought you wanted to use two different mappings, /web and /group for the first site and /web2 and /group2 for the second site. Altering those settings will affect all the sites -- and I'm not sure /web2 and /group2 is really any better than /web and /group emoticon
Zhenlei Li, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Junior Member Beiträge: 51 Beitrittsdatum: 13.07.14 Neueste Beiträge
Hi Andrew,
I am using LF CE GA6.2, does it have feature to allow me changing layout.friendly.url.private.group.servlet.mapping=/group2 and layout.friendly.url.public.servlet.mapping=/web2 ?
I have tried couple of times, but never got expected result. I found that -
After my portal init configuration,

If I directly edit /webapps/ROOT/WEB-INF/web.xml at following section
<servlet-mapping>
<servlet-name>Friendly URL Servlet - Private Group</servlet-name>
<url-pattern>/group2/*</url-pattern>
</servlet-mapping>
Then portal can be started, but cannot access http://localhost:8080 any more., no any error log but a warning log as:
01:29:15,598 INFO [liferay/hot_deploy-1][ResourcesImporterHotDeployMessageListe
ner:212] Group or layout set prototype already exists for company liferay.com
01:29:17,013 WARN [http-bio-8080-exec-1][code_jsp:128] {code="404", msg="/web/g
uest", uri=/}

Then I changed back web.xml to orignial version, and added portal-ext.properties with:
layout.friendly.url.private.group.servlet.mapping=/group2
#layout.friendly.url.private.user.servlet.mapping=/user
layout.friendly.url.public.servlet.mapping=/web2
and then restart tomcat, this time - public pages friendly url prefix changed to be
http://localhost:8080/web2/guest/welcome already.
but private pages still as http://localhost:8080/group/guest/xxxx
and links pointing to control_panel and private pages on the page changed to be /group2/xxx , but these are unreachable links.
this time the log show some warnning message like:
01:49:39,708 WARN [http-bio-8080-exec-6][code_jsp:128] {code="404", msg="/group2/control_panel", uri=/group2/control_panel}
01:49:42,869 WARN [http-bio-8080-exec-8][code_jsp:128] {code="404", msg="/web2/guest/welcome", uri=/web/guest/welcome}

even when I tried to re-login, there is no responding.
Hope I descripe the story clearly, that's why I said the changes crash the portal -- cannot login, many unreachabble links!
Struggle with this feature few days, but no luck.
I wonder if liferay CE GA6.2 can? can you share with me on how to do it before?
Thank you

Zhenlei

PS: answer your last question -- the main reason I want /group2 and /web2 is -- from reverse proxy team, I built 2 sites on 2 tomcat servers, the first site as /web and /group alreay, now second site going to be published by reverse proxy (Nginx) with single DNS. I have to make 2 portal site's url identified.
and 2 portal going to have same virtual host name.
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
You can definitely do it in 6.2 - that is in fact where I have used this many times. The key though is to make sure that the web.xml servlet mappings have the same values as the portal-ext.

So in your portal-ext

layout.friendly.url.private.group.servlet.mapping=/group2
layout.friendly.url.public.servlet.mapping=/web2


and then in your TOMCAT_HOME/webapps/ROOT/WEB-INF/web.xml find /group and /web and replace them with your /group2 and /web2. Restart the portal and all should be fine.

NOTE: if you have hard coded links anywhere in your solution though, rather than using the API to get the sites public and private group friendly urls, even these configurations will not work.
Zhenlei Li, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Junior Member Beiträge: 51 Beitrittsdatum: 13.07.14 Neueste Beiträge
Hi Andrew,

Zhenlei again. a good news I found that I can rename the /webapps/ROOT to /webapps/portal1
and then start Tomcat, access portal pages by http://localhost:8080/portal1/web/guest/welcome ; http://localhost:8080/portal1/group/guest/private-page1;
even for the Control Panel module, can reached through http://localhost:8080/portal1/group/control_panel?refid=xxxxx
I walked through the portal pages, functions, sounds ok. But the only worrying part on server startup logs, got errors as following:

2017-1-13 10:38:45 org.apache.catalina.startup.HostConfig deployDescriptor
淇℃伅: Deploying configuration descriptor D:\liferay-portal-6.2-ce-ga2\tomcat-7
.0.42\conf\Catalina\localhost\ROOT.xml
2017-1-13 10:38:45 org.apache.catalina.core.StandardContext resourcesStart
涓ラ噸: Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\liferay-portal-6.2-ce-ga2\t
omcat-7.0.42\webapps\ROOT does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.
java:138)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardConte
xt.java:5055)
at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5235)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
va:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfi
g.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2017-1-13 10:38:45 org.apache.catalina.core.StandardContext startInternal
涓ラ噸: Error in resourceStart()
2017-1-13 10:38:45 org.apache.catalina.core.StandardContext startInternal
涓ラ噸: Error getConfigured
2017-1-13 10:38:45 org.apache.catalina.core.StandardContext startInternal
涓ラ噸: Context [] startup failed due to previous errors
2017-1-13 10:38:45 org.apache.catalina.startup.HostConfig deployDirectory
淇℃伅: Deploying web application directory D:\liferay-portal-6.2-ce-ga2\tomcat-
7.0.42\webapps\calendar-portlet

I am not sure if they are fatal errors, what's the bad impact for it?
If this work, I will choose this solution, because this way provides a clear rule to reverse proxy team (let one Nginx talking with 2 portal server.)
please advice.

Have a nice day.
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: How to change the default access URL pattern? such as /group, /web/...

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
I think I am confused by what you are trying to do. Are you trying to install to separate instances of Liferay onto ONE Tomcat installation? If that is what you are trying to do you should really REALLY REEEEEEEEEEEEALLY not do that. If you are trying to have one physical machine host multiple Liferay installations, you should do multiple bundle installs and configure each of them to use a unique set of ports. For example -

Installation #1: /opt/liferay-a -- bind to 7070 -- access via http://www.yourhost.com:7070/web/guest

Installation #2: /opt/liferay-b -- bind to 8080 -- access via http://www.yourhost.com:8080/web/guest

Installation #3: /opt/liferay-c -- bind to 9090 -- access via http://www.yourhost.com:9090/web/guest

.. then you can have your proxy rewrite the inbound requests to go to the correct Liferay installation, but they are all separate. I've never even tried to have multiple Liferay installations on the same Tomcat. It has honestly never occurred to me to even try that as it sounds insane emoticon