404 handling, forum url rewrite

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
12/12/2008 4:41:27 AM
Nux
Gravatar
Total Posts 183

404 handling, forum url rewrite

Hey Joe,

2 question.

First, I'm having some problems with the 404 handling.

I have removed the custom error tags from the web.config, since this is only good for the user and not for search engines.
But now I don't have a correct 404 handling (Yes, I have set the 404 in IIS to a correct file).
So i wonder if it's not possible to add more handling of this in the code of Mojoportal?
There was a suggestion, but that lost it's focus since it went to logging. I haven't tested this, but would it be possible to make a 404 aspx page, which is customisable like other pages, but returns a 404 status? Just an idea. I'm thinking now to setup IIS that it handles everything with asp isapi and make a httpmodule for it.

Second question: would it be a lot of work, to make a forum with SEO friendly url's?
Something like /forums/date/title-of-the-topic.aspx. Difficult?

Stef

12/12/2008 6:38:14 AM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

Hi Stef,

Nothing stops you from creating a custom aspx page with inline code (no code behind file) and drop it in as your custom error page.

Keep in mind that it safer to use a plain html page for the error page, otherwise its possible your error page will itself throw errors.

In either case you should put the customErrors section back.

<customErrors mode="RemoteOnly" defaultRedirect="yourcustomerrorpage.aspx">
<error statusCode="404" redirect="~/PageNotFound.aspx" />
</customErrors>

If you want to use the defauolt IIS 404 page then remove this part:

<error statusCode="404" redirect="~/PageNotFound.aspx" />

I think it would be quite a bit of work to get that kind of friendly url in the forums and its not a high priority for me. Also I find google indexes my forums just fine. Can you point to any forums online that have this kind of url as you suggest? One of the problems is it still requires query string params for things like page number if the thread has more than one page. Another consideration is do I really want untrusted users to be able to create expressive urls in my site. I'm not sure its desireable to have urls like that in the forums. I've seen url schemes in forums that are perhaps more seo friendly than what we have now but not ones where the topic is expressed in the url.

In any case I think there are more important things to work on.

Best,

Joe

12/12/2008 7:06:55 AM
Nux
Gravatar
Total Posts 183

Re: 404 handling, forum url rewrite

Joe,

It's not the error page I'm talking about, but the 404 page.

Have you ever checked the status code of those <error statusCode="404" redirect="~/PageNotFound.aspx" /> page?
That is just a redirect and that gives a 200 code. So no 404 like google wants. I had troubles with webmasters tools, since there is no good 404 handling. And no, I don't want the webmasters tools verification meta tag in my html.
 

About the forum: if you think that the google index is just fine, ok for me than. I understand that there are more important things to work on.
Just to give you an online forum: http://forum.yetanotherforum.net/yaf_postst7342_Could-I-modify-the-font-size-in-the-Forum.aspx

Stef

12/12/2008 7:13:13 AM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

Perhaps you are right, maybe I should remove the

<error statusCode="404" redirect="~/PageNotFound.aspx" />

or maybe I should put code in that PageNotFound.aspx page to set the status to 404, perhaps that would be better?

What do you think would be better?

Joe

12/12/2008 7:30:14 AM
Nux
Gravatar
Total Posts 183

Re: 404 handling, forum url rewrite

The problem with that way of working, is that the url changes with a wrong page.
The url stays the same if you configure IIS correct. So I wouldn't give the pagenotfound.aspx a 404 status. It will always be that pages that gives a 404.

What to do best?

I have changed the IIS settings and putted a 404.html in the setting. That way, when I go f.i. to www.mysite.com/sdqfsdf, I get that 404.html.
If you go to www.mysite.com/sdqdsf.aspx, you get the asp.net error page:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /sdfsdf.aspx

So I wonder if you do that in debug mode, that the cursor is coming the code of the default.aspx (I guess everything of the normal things of the cms, so not the form, blog, ... is parsed via the default.aspx). If it comes in the page, you can check if that url is in the db (301 of normal db) and if not, you can say that the page is the 404 page (page with a fixed id in the db so we can also put modules on it) and render it and give it a 404 status code.

I'm doing things like that in our applications. But that will only work if you you can come in the default.aspx

Stef

12/12/2008 7:39:05 AM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

I will investigate a solution for this that doesn't require custom configuration of IIS. I think we can trap 404 errors in a handler and set the response without changing the url, and perhaps integrate the google 404 enhancement script.

Best,

Joe

12/12/2008 7:40:31 AM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

Heres a better link about the google 404 enhancement script.

12/12/2008 8:09:34 AM
Nux
Gravatar
Total Posts 183

Re: 404 handling, forum url rewrite

Ok, cool.

Must say that if you can do it in the default.aspx, you don't have to configure something in IIS.
I think that every page is captured with this. The only thing that will not work, is if you go to www.mysite.com/somethingthatdoesnotexist

One thing: please do not put that 404 widget standard in the 404 page. Make a module for this, so people can choose if they want that.

Stef

12/12/2008 12:13:14 PM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

Ok, I implemented better 404 handling (at least for .aspx and files handled by .NET).

I've updated this site with the new code. So for example if someone typos the url to the download page like this

http://www.mojoportal.com/dwnload.aspx

It will go to the 404 and google will suggest the correct download url

If you use Firebug you can see the status is 404.

I have some other things to finish before I can merge this to trunk. Currently its in my sandbox and it will only compile at the moment for MySql because I haven't implemented some new web store methods in MS SQL yet. Should have it in ther by tomorrow night though.

This was a good suggestion, the previous handling of 404s was masking 404s from google for .aspx pages.

Its possible to disable the handler by commenting out the httpmodule in Web.config

<add name="PageNotFoundHandler" type="mojoPortal.Web.PageNotFoundHttpModule, mojoPortal.Web" />

and you can disable the google enhancement by setting this to false in user.config

<add key="EnableGoogle404Enhancement" value="true" />

Its also possible to render a custom 404 page using this setting:

<add key="Custom404Page" value="/PageNotFound.aspx" />

you can put a different .aspx page or even a plain html page.

The built in PageNotFound.aspx is nice because it shows the skin and menu. Seems a pretty good solution.

Best,

Joe

 

 

 

12/14/2008 2:50:54 PM
Nux
Gravatar
Total Posts 183

Re: 404 handling, forum url rewrite

Looking forward to the next release.

Thanks
Stef

12/15/2008 7:19:50 AM
Gravatar
Total Posts 18439

Re: 404 handling, forum url rewrite

The 2.2.8.0 release is now available.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.