Wordpress Simple 301 Redirect Plugin problem..

11 replies
I used this plugin to do a 301 and it worked perfectly. However I'm trying to UNDO it now and simply erasing it doesn't do it. I'm not sure what to do.. I was peeking around the plugin file.. any tips on how to undo this would be appreciated

PHP Code:
        /*
            save the redirects from the options page to the database
        */
        
function save_redirects($data)
        {
            
$redirects = array();
            
            for(
$i 0$i sizeof($data['request']); ++$i) {
                
$request trim($data['request'][$i]);
                
$destination trim($data['destination'][$i]);
            
                if (
$request == '' && $destination == '') { continue; }
                else { 
$redirects[$request] = $destination; }
            }

            
update_option('301_redirects'$redirects);
        }
        
        
/*
            Read the list of redirects and if the current page 
            is found in the list, send the visitor on her way
        */
        
function redirect()
        {
            
// this is what the user asked for (strip out home portion, case insensitive)
            
$userrequest str_ireplace(get_option('home'),'',$this->getAddress());
            
$userrequest rtrim($userrequest,'/');
            
            
$redirects get_option('301_redirects');
            if (!empty(
$redirects)) {
                foreach (
$redirects as $storedrequest => $destination) {
                    
// compare user request to each 301 stored in the db
                    
if(urldecode($userrequest) == rtrim($storedrequest,'/')) {
                        
header ('HTTP/1.1 301 Moved Permanently');
                        
header ('Location: ' $destination);
                        exit();
                    }
                    else { unset(
$redirects); }
                }
            }
        } 
// end funcion redirect 
#301 #redirect #simple #wordpress
  • Profile picture of the author marigot
    Are you trying to undo the whole plugin or just one redirect that you setup?

    If you do not want the plugin anymore, go into your WP dashboard under Plugins and "deactivate" it.

    If you are trying to remove one redirect, then go into the settings and delete it.
    {{ DiscussionBoard.errors[3279766].message }}
  • Profile picture of the author Bryan V
    I have removed the redirect from settings, deactivated, and uninstalled it yet the redirect still remains.
    Signature
    Perhaps an attic I shall seek.
    {{ DiscussionBoard.errors[3279794].message }}
  • Profile picture of the author Patrick
    Check your function.php file, if it contains that code.

    Delete it and check.

    Make sure you keep a backup of this fille.
    {{ DiscussionBoard.errors[3279800].message }}
  • Profile picture of the author Bryan V
    Thanks Warriors everything is working now
    Signature
    Perhaps an attic I shall seek.
    {{ DiscussionBoard.errors[3279818].message }}
    • Profile picture of the author JohnyData
      Hey Pack12, I know you said this issue was resolved, but I want to post for future reference for you and others who may have this same issue.

      The thing about 301 redirects is that they seem to like to stay resident for a short while, even after you have changed them or deleted them all together.

      I learnt this the hard way a while ago. I made a typo when creating a redirect and didn't realize it until a customer of mine pointed it out.

      I changed the redirect code but the old redirect was still being used.

      The good news, however, is that anyone who had not yet visited the link, DID get sent through to the new link, so, I assume this is an issue with the ISP provider's DNS cache (I could be wrong, just a guess).

      Next time you want to change/delete a redirect and test to make sure it was changed/deleted, use a proxy to visit the redirect after your modify it and you should see the proper results.

      HTH
      {{ DiscussionBoard.errors[3280802].message }}
      • Profile picture of the author SteveJohnson
        Originally Posted by jonathon View Post

        Hey Pack12, I know you said this issue was resolved, but I want to post for future reference for you and others who may have this same issue.

        The thing about 301 redirects is that they seem to like to stay resident for a short while, even after you have changed them or deleted them all together.

        ...

        The good news, however, is that anyone who had not yet visited the link, DID get sent through to the new link, so, I assume this is an issue with the ISP provider's DNS cache (I could be wrong, just a guess).

        Next time you want to change/delete a redirect and test to make sure it was changed/deleted, use a proxy to visit the redirect after your modify it and you should see the proper results.

        HTH
        Sort of right. Redirects are cached in the visitor's browser, by design. If the browser encounters a 301 redirect (supposedly permanent) it makes a note to itself to request the new address on any subsequent visits. That's why when you're testing redirects you should always use 302-Temporary until you're sure they're working correctly.
        Signature

        The 2nd Amendment, 1789 - The Original Homeland Security.

        Gun control means never having to say, "I missed you."

        {{ DiscussionBoard.errors[3281372].message }}
  • Profile picture of the author JohnyData
    Hey Steve, thanks for the clarification. Hopefully the OP understood my suggestion none the less
    {{ DiscussionBoard.errors[3281405].message }}
    • Profile picture of the author SteveJohnson
      Originally Posted by jonathon View Post

      Hey Steve, thanks for the clarification. Hopefully the OP understood my suggestion none the less
      No problem. Using a proxy is a good suggestion.
      Signature

      The 2nd Amendment, 1789 - The Original Homeland Security.

      Gun control means never having to say, "I missed you."

      {{ DiscussionBoard.errors[3281464].message }}
  • Profile picture of the author Bryan V
    Ah alright I'm going to resurrect this.. having the same issue again with the 301. I'm not exactly sure how it resolved last time, maybe you guys can help.

    My root is redirecting to a subpage..
    I have removed and deleted the 301 plugin, and checked the htaccess file of that wordpress install, and it is clean.

    Ive tried running ccleaner, behind a proxy, both, and from another computer/phone and it is still redirecting.

    Any idea what can still be causing the redirect?
    Signature
    Perhaps an attic I shall seek.
    {{ DiscussionBoard.errors[3489728].message }}
  • Profile picture of the author Bryan V
    Ok my host said it's not domain redirection on their end, so it's probably some htaccess file "somewhere, that affect folders server wide".

    I thought that htaccess only affected folders underneath it not above it.

    I have also installed prettylink in the past and removed it.. not sure if it stores info somewhere other than the plugin folder..
    Signature
    Perhaps an attic I shall seek.
    {{ DiscussionBoard.errors[3495027].message }}
    • Originally Posted by pack12 View Post


      I thought that htaccess only affected folders underneath it not above it.
      That all depends on the rewrite base command.

      its definitely htaccess.

      I can look into this for you for a small fee.
      {{ DiscussionBoard.errors[3495272].message }}

Trending Topics