• Resolved MrSlartibartfast

    (@mrslartibartfast)


    I’m using the plugin for a good while now, and we’re really happy with it.
    On the website I’m working on we have set up the creation of redirects with the PHP Api, this worked fine until a month or so ago, but I can’t pin point the exact time it stopped (I didn’t regularly update the plugin, we do have the latest version at the moment though).

    I’m using Red_Item::create ( from the documentation https://redirection.me/developer/php-api/ ) to set up 301 redirects, and at the moment the redirects created don’t work anymore.
    The change I see is that they are created with the following option selected:
    Match: “URL and server
    If I’m updating this manually to “URL only” (and update the target url) it works.

    So this is what we set up at the moment – it probably just needs some parameter to be updated I guess so the redirect is set to “URL only” from the start:

    
    $redirectData = array(
     'url' => $fromURL,
     'action_code' => 301,
     'action_data' => array('url' => $toURL),
     'action_type' => 'url',
     'match_type' => 'url',
     'match_data' => array(
       'source' => array(
          "flag_case" => true, 
          "flag_trailing" => true
       )
     ),
     'group_id' => 1
    );
    
    $result = @Red_Item::create($redirectData);
    
    //result processing follows
    

    The vars $fromURL and $toURL contain the source and target url.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Godley

    (@johnny5)

    Is the fromURL an absolute URL? If it is, and the domain or protocol is different to the current one, then it will be converted to URL and server match. If you remove the protocol and domain from the source URL then this will never happen.

    Thread Starter MrSlartibartfast

    (@mrslartibartfast)

    Thanks for your response.
    Yes looks like that is the issue – the fromURL is an absolute URL and the URL to be redirected to is a relative path. Both on the same server, but I’ll remove the protocol and domain from the from URL since its not needed actually.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP API Red_Item parameters update – something changed’ is closed to new replies.