Page redirection on error

22726, modified 17 Years ago. Regular Member Posts: 110 Join Date: 7/3/06 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
thumbnail
362673, modified 17 Years ago. Regular Member Posts: 234 Join Date: 1/1/08 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.
22726, modified 17 Years ago. Regular Member Posts: 110 Join Date: 7/3/06 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
thumbnail
413654, modified 17 Years ago. Junior Member Posts: 61 Join Date: 1/22/08 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?
thumbnail
308319, modified 16 Years ago. Junior Member Posts: 48 Join Date: 12/2/07 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
thumbnail
323016, modified 16 Years ago. New Member Posts: 14 Join Date: 12/10/07 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
thumbnail
2401061, modified 16 Years ago. Liferay Legend Posts: 2034 Join Date: 3/5/09 Recent Posts
The thread is still valid... but there doesn't seem to be a good answer yet.
thumbnail
1599526, modified 16 Years ago. New Member Posts: 21 Join Date: 11/18/08 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,

[indent]VALID URL: http://localhost/group/cp/home[/indent]
[indent]Invalid URL: http://localhost/group/cp/badhome[/indent]

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

[indent]http://localhost/blahblahBADurl[/indent]
thumbnail
308319, modified 16 Years ago. Junior Member Posts: 48 Join Date: 12/2/07 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?
thumbnail
308319, modified 16 Years ago. Junior Member Posts: 48 Join Date: 12/2/07 Recent Posts
Ah - finally got it. emoticon

The magic is in the /errors/404.jsp file (which is being pointed at by liferays web.xml file

Detailed solutions is also describen in this blogpost about the 404 error with liferay

Thanks again!
thumbnail
4632302, modified 15 Years ago. New Member Posts: 3 Join Date: 2/20/10 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, modified 14 Years ago. Regular Member Posts: 159 Join Date: 8/24/10 Recent Posts
Thanks Drew. Good solution. We can override status.jsp if we want this to work for all status code
thumbnail
jelmer kuperus, modified 14 Years ago. Liferay Legend Posts: 1191 Join Date: 3/10/10 Recent Posts
I did this : http://www.liferay.com/community/forums/-/message_boards/message/11279721