Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter MikeySmithy

    (@mikeysmithy)

    Hi guys,

    just gave it some more tests. I think right now the plugin does not handle parameters correctly. It should just generally ignore all parameters. Right now it treats all parameters as part of the url – which is nonsense. :-O

    When disabling the plugin I can call “https://www.mydomain.com/page/?testparameter=value” with no problem. The 404 redirect should only get active if the url itself (WITHOUT the parameter) has no match.

    Is there are fix for this?

    I would be really thankfull for a tip. ??

    Kind regards
    Mikey

    I found a fix for this. Make this change in frontend.php around line 57:

    function wbz404_process404() {
    	$options = wbz404_getOptions();
    	$urlRequest = $_SERVER['REQUEST_URI'];
    	$urlParts = parse_url($urlRequest);
    	$requestedURL = $urlParts['path'];
    	$requestedURL .= wbz404_SortQuery($urlParts);
    
    //------- CHANGE to allow ? paramaters
    if (count($_GET) == 0){
    
    //Get URL data if it's already in our database
    	$redirect = wbz404_loadRedirectData($requestedURL);
    }

    there is a better fix:

    Open the ‘functions.php’ in /wp-content/plugins/404-redirected/includes and do following change:
    in function wbz404_SortQuery(...) (Line 465) replace all preg_split with explode
    This is what the code should look like:

    [...]
    	$queryParts = explode("&", $urlQuery);
    	foreach ($queryParts as $query) {
    		if (strpos($query, "=") === false) {
    				$queryString[$query]='';
    		} else {
    				$stringParts = explode("=", $query);
    				$queryString[$stringParts[0]]=$stringParts[1];
    		}
    	}
    [...]

    Your code is not making any difference for me, neXorianus. I fail to understand how replacing preg_split with explode will make this plugin ignore parameters. Would you care to elaborate?

    I have the following URL: https://domain.no/158-some-old-url?adjust=1&from=0&iid=1480&pid=Domain-Article-Paragraphs.Domain-ParagraphText-Picture&r_n_d=42304_&x=512

    What I need is to ignore everything after the ?, because the URL https://domain.no/158-some-old-url redirects just fine.

    Thread Starter MikeySmithy

    (@mikeysmithy)

    Hi guys,

    are there any news on this one?

    I just re-stumbled about this problem again.

    I think in general everything behind the “?” in the url “www.domain.com/?” should be ignored.

    Any ideas?

    The fix I posted before works fine and any URL with a /? does not get redirected.

    Gyn3r the function returned empty.
    so I started debugging it, and I noticed, that the first preg_split always returns empty.

    So I replaced it (and the other preg_split) with the (lighter) explode. This fixed the problem (for me)

    yogabasics, your solution works, until a Parameter produces a 404 page. Those 404 Pages wont be tracked and wont be redirected (as you said).
    An Example: An Event plugin that refers to the Months with parameter. ?month=13 would result into an 404 page because there is no 13th month. so the Plugin cannot redirect it to any page.

    Addition:

    If you have problems with Permalinks and url parameters, try disabling the Option “Force current permalinks” under “404 Redirected -> Options”

    This solved pagination problems with “the Eventmanager” plugin for me.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to ignore certain URL-parameters, p.e. /home/?parameter=test’ is closed to new replies.