Loading...
 
Features / Usability

Features / Usability


HTTP 404's or Redirects

posts: 53 Australia

Hi,

I installed Tiki Wiki a few months ago. Previously I was using Joomla.
There are a few sites which link to mine, which use URLs that Tiki does not understand. On top of that, the articles they link to no longer exist.

An example of this is:
http://networkdirection.net/index.php?option=com_content&view=article&id=68%3Awindows-internal-database-memory-limit&Itemid=58

Clicking on this link displays the error:
Notice: invalid variable value: $_GET%22id%22 = 68:windows-internal-database-memory-limit

Is there a way to return an HTTP 404/410, or redirect to the homepage or something like that?


Thanks

posts: 214

That is an interesting problem. It might be nice if Tiki recognized that it was a Joomla request and did a redirect, but I do not find any way to do that. It is giving that error because of how it is interpreting the passed parameters.
There is a Tiki supplied index.php file, and it does an include for tiki-setup.php, and tiki-setup.php in turn does and include for tiki-setup_base.php. The tiki-setup_base.php checks the URL for parameters and then checks if they are valid, and Joomla and Tiki have the "id=" parameter in common. Tiki does not recoginze it as an incorrect Joola request and tries to evaluate the "id=" parameter. The check finds that the value is not an integer (it finds "id=68%3Awindows-internal-database-memory-limit") and it throws the error.

I can suggest 2 modifications that you could consider, I'm not sure that either of them are good options though. Maybe someone else can offer something better.

One thing you could do is add code to tiki-setup_base.php where it checks the passed parameters and add a check for the Joomla "option=com_content"

In tiki-setup_base.php, the code that checks the parameters is:

Copy to clipboard
function varcheck(&$array, $category) { global $patterns, $vartype, $prefs; $return = array(); if (is_array($array)) { foreach ($array as $rq => $rv) { // check if the variable name is allowed if (!preg_match($patterns['vars'], $rq)) { ...


You could insert a check for the "option=com_content" parameter:

Copy to clipboard
function varcheck(&$array, $category) { global $patterns, $vartype, $prefs; $return = array(); if (is_array($array)) { foreach ($array as $rq => $rv) { // if option=com_content then go to home page if ($rq == "option" && $rv == "com_content") { $accesslib = TikiLib::lib('access'); $accesslib->redirect($homePageUrl); } // check if the variable name is allowed if (!preg_match($patterns['vars'], $rq)) { ...


That would redirect it to the home page if the joomla "option=com_content" parameter is present.

Maybe a cleaner option would be to add a check for the joomla "option=com_content" parameter in the .htaccess file.
You could add this after the "RewriteEngine On" statement in the .htaccess file:

Copy to clipboard
RewriteCond %{THE_REQUEST} option=com_content RewriteRule ^.*$ /HomePage? [R,L]

That would redirect requests to /HomePage if they contained "option=com_content" (or you could put in some other page name).
The "?" after the page name is needed to strip the original parameters, otherwise it will insert the parameters after the new page name and it will still cause an error.

You could also set the flags to [R=404,L] which would give them a Not Found error, but the message:
"The requested URL /index.php was not found on this server." would be incorrect because the /index.php file is there.

Tom

posts: 53 Australia

The rewrite in the htaccess file worked perfectly!

Thanks for your suggestion :-)


Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting