Message Boards

How to remove '/o' prefix from url in Liferay 7.1

Bony Antony, modified 4 Years ago.

How to remove '/o' prefix from url in Liferay 7.1

New Member Posts: 5 Join Date: 10/16/19 Recent Posts
In my Liferay 6.2 I had made a module named 'create-user-spring' which is build using spring. In this module I created a method named 'createUser' with request mapping(@RequestMapping(value="/create-user")). 
This is working perfectly in 6.2 when I hit the below url:
'localhost:8080/create-user-spring/service/create-user' .But in Liferay 7.1 the link outputs 'resource not found'.
When I change the url with ''localhost:8080/o/create-user-spring/service/create-user'', it works perfectly. Is there any way to remove ' /o' from url in Liferay 7.1?orIs there any way to use the same url of Liferay 6.2 in 7.1 by mapping or any other way?
 
Vishal Kamlani, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

New Member Post: 1 Join Date: 10/15/19 Recent Posts
I also faced similar kind of issue. I tried solving this using filter, but it didn't worked for me. Any different approach will be appreciated.
thumbnail
David H Nebinger, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Using a filter absolutely can work, I've done it many times.

The best alternative though is to use URL rewriting in your apache or nginx tier to handle paths without the /o prefix.
Nikunj Mori, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

New Member Posts: 2 Join Date: 12/7/19 Recent Posts
Thanks David for your reply.

I am facing the same problem.

Using Filter, again we need '/o' in url to reach to the Filter.



Yaah, Using URL rewriting I am able to get the proper response in positive scenario.



But if any error or exception occurs in method execution, it simply returns the blank screen with status code 200 OK.

Like Method Not Allowed, or

Parameters is Missing.

I am not able to understand this behaviour, means in positive scenario its showing same results as like with '/o' , but in negative scenario URL with '/o' showing proper status code with error message where without '/o' showing just blank screen with status code 200 OK.



Can you please provide the solution for the same?

Thanks.
thumbnail
Olaf Kock, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Nikunj Mori:

Using Filter, again we need '/o' in url to reach to the Filter.
a pragmatic idea: it might be easier to make the URL configurable in your app (and bite the bullet to include the URL) than to introduce ambiguities in the server-side URLs. Maybe the current assumption about the URLs triggered by an app isn't that good...
Nikunj Mori, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

New Member Posts: 2 Join Date: 12/7/19 Recent Posts
Thanks Olaf for your reply.what is the ideal way of handling the url redirect in our app? 
So that i can compare it with my implementation and see what's wrong? 
Also if you could share any links or any sample code to try then it would be great. 
Thanks.
thumbnail
David H Nebinger, modified 4 Years ago.

RE: How to remove '/o' prefix from url in Liferay 7.1

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
Nikunj Mori:

Using Filter, again we need '/o' in url to reach to the Filter.

That's untrue, who gave you that impression?

You can write a standard servlet filter, bind it to /my-path/*, and the implementation can get the dispatcher and redirect to /o/my-path/... in order to kick it to the OSGi implementation.