WordPress.org

Ready to get started?Download WordPress

Forums

404 Redirected
How to ignore certain URL-parameters, p.e. /home/?parameter=test (9 posts)

  1. MikeySmithy
    Member
    Posted 1 year ago #

    Hi guys,

    I really like this plugin, but just came to a point where it is giving me problems.

    For my statistics I need to be able to call an url INCLUDING a parameter.
    For example:

    http://www.mydomain.com/page/?testparameter=value

    Right now the plugin would handle this as a redirect and my javascript (where I want to process the parameter) will not see the value.

    Any ideas?

    Kind regards
    Mikey

    http://wordpress.org/plugins/404-redirected/

  2. MikeySmithy
    Member
    Posted 1 year ago #

    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 "http://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

  3. yogabasics
    Member
    Posted 7 months ago #

    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);
    }
  4. neXorianus
    Member
    Posted 6 months ago #

    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];
    		}
    	}
    [...]
  5. Gyn3r
    Member
    Posted 6 months ago #

    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: http://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 http://domain.no/158-some-old-url redirects just fine.

  6. MikeySmithy
    Member
    Posted 6 months ago #

    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?

  7. yogabasics
    Member
    Posted 6 months ago #

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

  8. neXorianus
    Member
    Posted 6 months ago #

    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.

  9. neXorianus
    Member
    Posted 6 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.