[Solved] Forum Redirect Issue (possible bug in CMSMS core)

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
Ricko97
Forum Members
Forum Members
Posts: 65
Joined: Wed Jan 07, 2009 10:14 pm

[Solved] Forum Redirect Issue (possible bug in CMSMS core)

Post by Ricko97 »

Right, where to begin...

I have noticed that the Forum Made Simple module results in 404 Not Found errors when utilizing one of the CMSMS redirect() functions.

For example: suppose I have an installation of FMS that displays the forum on the "community" page. I go to www.mysite.com/community, pick a forum, and hit "New Topic".

Then, as soon as I hit "Submit", I get a 404 because the URL looks like this:

http://www.mysite.com/community?mact=Fo ... id=18(etc)

...when it should actually look like this:

http://www.mysite.com/index.php?mact=Fo ... id=18(etc)

So, let's run through the background logic... what's happening is this:

1) I go to my forums and pick a forum section (action.default.php)
2) I hit "New Topic": the module executes action.new_topic.php
3) I enter some random stuff for subject line and post body, then hit "Submit": the module executes action.new_topic.php again, but this time the IF statement that checks to see if a form was submission was sent returns true.
4) The code inside the above mentioned IF statement is executed, including the relevant SQL queries to enter the new topic data into the database. But when it reaches this line:

Code: Select all

$this->Redirect($id, $forum_det['redirect'], $returnid, $arr_url, true);
...I get a 404, because it sends my browser to /community?params instead of /index.php?params - almost like it's trying to do raw URLs and Pretty URLs both at once!

Now, I am aware that $this->Redirect is referring to a CMSMS core function and not a function of the module itself, but I'm wondering if there's a way of fixing the problem in the module, since it doesn't seem to happen in any other module I've used.

So does anyone have any suggestions? I do use Lighttpd, so it might just be an issue with Lighttpd not liking the way CMSMS handles certain redirects, but like I said above; I've never seen it happen with any other module. Is there a way of forcing certain links/URLs in a module to be strictly raw/"non-Pretty"?
Last edited by Ricko97 on Wed Nov 24, 2010 12:45 pm, edited 1 time in total.
NaN

Re: Forum Redirect Issue (possible bug in CMSMS core)

Post by NaN »

It seems that you don't use a page extension but pretty urls.
I would suggest to use a slash as page extension and redirect all requests that does not contain a trailing slash to contain one using .htaccess.
So it should always redirect to

http://www.yoursite.com/community/?mact ... id=18(etc)

(just an idea wihout hacking the code)
User avatar
Ricko97
Forum Members
Forum Members
Posts: 65
Joined: Wed Jan 07, 2009 10:14 pm

Re: Forum Redirect Issue (possible bug in CMSMS core)

Post by Ricko97 »

Actually, I did originally have '/' as a page extension, but the problem still existed in that case and it actually made matters worse for other modules. I guess I should have mentioned that in the OP, sorry.

That said, it doesn't leave a whole lot of room for identifying the cause. But you do have an interesting point...

http://www.yoursite.com/community/?mact ... id=18(etc)

...is that really a valid URL? If it is, then I suppose I can re-enable the / page extension and try tweaking my lighttpd rewrite rules to handle URLs such as the above.

Thanks for your reply.

EDIT: actually, I guess that's a stupid question. It just occurred to me that whether or not the URL is "valid" depends very much on the rewrite rules. ::) ...but if there's a way of fixing the issue in the module code, I would much rather do that than try to wrap my head around Lighttpd rewrite rules.
Last edited by Ricko97 on Wed Nov 24, 2010 12:19 am, edited 1 time in total.
NaN

Re: Forum Redirect Issue (possible bug in CMSMS core)

Post by NaN »

Is it CMSms 1.9 or 1.9.1 ?
Something has changed to the redirect functions to fix a problem with SSL.
I don't know if this causes your problem.
The redirect function uses the GetUrl() function to get the current page url.
If there are params it appends the params to that url.
If you use pretty urls in your case the current page url is

http://www.yoursite.com/community

This will result in a 'faulty' url if the params are just appended.
(By the way on my localhost it works. Seems to be server specific.)

If you use a page extension like '.html' (or a slash) the current page url would result in

http://www.yoursite.com/community.html
or
http://www.yoursite.com/community/

if you now append the params it is a valid url.

This one

http://www.yoursite.com/community/?mact ... id=18(etc)

should be a valid url. (but maybe also depends on the server)
Without .htaccess rewrite rules it would be the same like

http://www.yoursite.com/community/index ... id=18(etc)

but this won't be found either, since there is no "community" directory.
This is why you need .htaccess rewrite rules that rewrites the url to

http://www.yoursite.com/index.php?mact= ... id=18(etc)

As i recall the default .htaccess rewrite examples in the doc folder should work on most Apache servers. But i don't know about Lighttpd.

It seems to be no error in the module. And not really an error in the core either.

The problem is: You cannot 'fix' it in the module. To 'fix' that for your particular problem you would need to modify the core function that performs the redirect. You should check if there is no page extension but mod_rewrite. If so the function should just append a slash to the GetUrl() result or instead of the GetUrl() function just use the root url + index.php + params (i guess this was the old way).

This is why i suggest to tweak some settings of the CMS / Server.
It would be better than some server specific hacks that are only for certain installs.
Last edited by NaN on Wed Nov 24, 2010 11:46 am, edited 1 time in total.
User avatar
Ricko97
Forum Members
Forum Members
Posts: 65
Joined: Wed Jan 07, 2009 10:14 pm

Re: Forum Redirect Issue (possible bug in CMSMS core)

Post by Ricko97 »

It seems you were almost spot on!

I am using CMSMS 1.9.1 and I tried changing the page extension, but the problem still occurred. However, I found an updated version of the Lighttpd rewrite rules on the wiki:

Code: Select all

url.rewrite-if-not-file = (
	"^/(admin)/(.*)$" => "/$1/$2",
	"^/([^.?]*)(\?(.*))?$" => "/index.php?page=$1&$3"
)
...and that, coupled with a '/' page extension, appears to work beautifully.  ;D

I might run into URL problems elsewhere having done this, but the subject of this topic is FMS-specific, so I'll mark it as [solved].

Thanks a lot for your suggestions, NaN.
Post Reply

Return to “Modules/Add-Ons”