Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Luis Colorado
Page redirection on error
April 11, 2008 12:24 AM
Answer

Luis Colorado

Rank: Regular Member

Posts: 110

Join Date: July 2, 2006

Recent Posts

Hi!

I just upgraded from 4.2 to 4.4, and I have noticed that whenever I enter an invalid URL, Liferay graciously redirects my page to the latest valid page. So if I enter:

http://localhost:8080/ljasdflkjasflj

It will redirects me automatically to my last valid page.

This is a nice feature for the end users, but for me it's very annoying. I just want to see the error messages! I want to know what went wrong! I'm having a lot of trouble to find out what's wrong with my old portlets.

It is possible to disable this behavior?

Thank you all in advance!

Luis
Arcko Duan
RE: Page redirection on error
April 11, 2008 1:35 AM
Answer

Arcko Duan

LIFERAY STAFF

Rank: Regular Member

Posts: 234

Join Date: January 1, 2008

Recent Posts

try

#
    # Redirect to this resource if the user requested a friendly URL that does
    # not exist. Leave it blank to display nothing.
    #
    # Note: For backward compatibility, this overrides the property
    # "layout.show.http.status" for the 404 status code.
    #
    #layout.friendly.url.page.not.found=/html/portal/404.html


in portal.properties.
Luis Colorado
RE: Page redirection on error
April 16, 2008 11:24 AM
Answer

Luis Colorado

Rank: Regular Member

Posts: 110

Join Date: July 2, 2006

Recent Posts

I added the following line to portal-ext.properties at ROOT/WEB-INF/classes:

layout.show.http.status=true

However, I still get the same behavior. If I use the following URL:

http:localhost:8080/ljasdfljasdf

I get redirected to my last valid page.

Then, I tried the following line in portal-ext.properties instead:

layout.friendly.url.page.not.found=/html/portal/404.html

And I still got redirected to my last valid page.

Finally, I tried both:

layout.show.http.status=true
layout.friendly.url.page.not.found=/html/portal/404.html

But, again, I still got redirected to my last valid page.

Apparently, my settings don't make any difference. I checked, and these properties show up in the Admin portlet.

So, what gives? What's going on?


Any ideas?

Thank you all,

Luis
Pablo Mosquera Sáenz
RE: Page redirection on error
April 17, 2008 1:48 AM
Answer

Pablo Mosquera Sáenz

Rank: Junior Member

Posts: 61

Join Date: January 22, 2008

Recent Posts

I tried with a friendly url like

layout.friendly.url.page.not.found=/web/company/error404
and its an error page in my portal

layout.friendly.url.page.not.found=/html/portal/error404.jsp should work too

I have another question. This is just one error page, but there for example another error page (error.jsp). I have a problem with this page and it is that when there is an error the error.jsp is displayed in the default liferay comunity and look and feel (perhaps it is bacause it is under common folder). I want to display this page within my theme, with my navigation bar, and with my look and feel. Any idea?
Simon Prinzleve
RE: Page redirection on error (404)
September 6, 2009 3:06 AM
Answer

Simon Prinzleve

Rank: Junior Member

Posts: 48

Join Date: December 2, 2007

Recent Posts

Hello,

I tried to do the same - these are my setting in portal-ext.properties:

layout.show.http.status=true
layout.friendly.url.page.not.found=/errors/404.jsp

Note: I'm on 5.2.2. - and I discovered the jsp file /errors/404.jsp
But neither with the 404.jsp by liferay nor with an own error file I got it working.

I'm still being redirected to /web/guest - regardles whether I'm signed in or not.

Any additional advices? I'm going mad!
(Especially as google hates a 200 status for a page not found..)

Thank you so much!

Simon

--- update 6th Sept

I did some additional tests
- setting up a liferay page for the error message (/web/guest/error)
- playing with similar parameters like auth.forward.by.last.path=false

all without success

Maybe it has to something to do with the fact that I migrated from 4.3.5? (Over several stages)
I have those legacy setting:

resource.repositories.root=${user.home}/liferay

theme.portlet.sharing.default=true

organizations.country.required[regular]=true
organizations.assignment.auto=true
organizations.assignment.strict=false
organizations.membership.strict=true
permissions.user.check.algorithm=2

layout.user.private.layouts.power.user.required=true

I am a bit desperate by now... any idea?


----
----
Blog about liferay for the internet
Anika Hofmann
RE: Page redirection on error (404)
September 13, 2009 6:27 AM
Answer

Anika Hofmann

Rank: New Member

Posts: 14

Join Date: December 9, 2007

Recent Posts

Hi Simon!

It seems to me no-one is watching this old thread anymore. Maybe you just start a new post should be interesting for me too!

Thanks, Anika
Lisa Simpson
RE: Page redirection on error (404)
September 15, 2009 4:22 PM
Answer

Lisa Simpson

Rank: Liferay Legend

Posts: 2034

Join Date: March 5, 2009

Recent Posts

The thread is still valid... but there doesn't seem to be a good answer yet.
Chris Kauffman
RE: Page redirection on error (404)
November 3, 2009 1:35 PM
Answer

Chris Kauffman

Rank: New Member

Posts: 21

Join Date: November 18, 2008

Recent Posts

I ran into this issue today as well.

There are actually two problems here.
1. If the user mangles only the last part of the URL, then the setting in portal.properties (or more properly in portal-ext.properties) works fine. For example,

VALID URL: http://localhost/group/cp/home

Invalid URL: http://localhost/group/cp/badhome


The second url will get redirected to whatever value I set for layout.friendly.url.page.not.found=

2. If the user mangles everything immediately after the domain, then liferay doesn't handle it. You app server does. If you are running on Tomcat or JBoss or whatever, it has its own page not found functionality which you have to configure

http://localhost/blahblahBADurl
Simon Prinzleve
RE: Page redirection on error (404)
November 15, 2009 8:57 AM
Answer

Simon Prinzleve

Rank: Junior Member

Posts: 48

Join Date: December 2, 2007

Recent Posts

Hey Chris,

thanks a lot - that really helps.

So for 1) I'm fine now.

How about 2)
I'm using the liferay-tomcat bundle - so this tomcat has been configured by liferay.

Where can I adjust the standard behaviour to route everything to the default liferay guest URL? ( /web/guest if not reconfigured)

I want just / to route to the standard guest url ( /web/guest )
I want everything else (like /blabla ) to route to a error page with an 404

I would do this with apache - but as I am using liferay for multiple virtual hosts (using multiple portal instances) this might be a bit tricky.

Any ideas?
Drew Poggemann
RE: Page redirection on error (404)
November 10, 2010 8:15 AM
Answer

Drew Poggemann

Rank: New Member

Posts: 3

Join Date: February 20, 2010

Recent Posts

Hi everyone, I know this post is older but I thought I would add something I found because we needed to have community based 404 page so we did the following to accomplish this.

1. Currently the /errors/404.jsp page in the ROOT webapps is what is called.
2. I modified the web.xml to point to a new custom page that is exactly the same as the original but we did the following change to go to a defined friendly url of "/pagenotfound" that can be created as a page in each community.
3. If the page does not exist in the community then it will do the following based on default liferay capabilities
a. Go to the last page navigated in the community
b. If first time going to site it will go to top page in community page hierarchy

The new 404 page we created (and then pointed to in the web.xml) will have the same code as 404 page with minor changes as identified below to go to the pagenotfound page in the community.

...
LayoutSet layoutSet = (LayoutSet)request.getAttribute(WebKeys.VIRTUAL_HOST_LAYOUT_SET);

if (layoutSet != null) {
if ("/pagenotfound".equals(PortalUtil.getCurrentURL(request))) {
redirect = PortalUtil.getPathMain();
}
else {
// Redirect to page in the community if the page exists
redirect = "/pagenotfound";
}
}
else {
redirect = PortalUtil.getHomeURL(request);
}
...

Hopefully this helps anyone that needed to do the same thing. If there are better ways to do this that I missed, I would love your input.

Thanks,

Drew
Roshan Qureshi
RE: Page redirection on error (404)
December 30, 2011 6:22 AM
Answer

Roshan Qureshi

Rank: Junior Member

Posts: 63

Join Date: August 24, 2010

Recent Posts

Thanks Drew. Good solution. We can override status.jsp if we want this to work for all status code
jelmer kuperus
RE: Page redirection on error (404)
December 30, 2011 6:36 AM
Answer

jelmer kuperus

Rank: Liferay Legend

Posts: 1075

Join Date: March 10, 2010

Recent Posts

I did this : http://www.liferay.com/community/forums/-/message_boards/message/11279721