Wordpress Simple 301 Redirect Plugin problem..

by 11 replies
14
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 
#programming #301 #redirect #simple #wordpress
  • 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.
    • [ 1 ] Thanks
  • I have removed the redirect from settings, deactivated, and uninstalled it yet the redirect still remains.
  • Check your function.php file, if it contains that code.

    Delete it and check.

    Make sure you keep a backup of this fille.
    • [ 1 ] Thanks
  • Thanks Warriors everything is working now
    • [1] reply
    • 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
      • [1] reply
  • Hey Steve, thanks for the clarification. Hopefully the OP understood my suggestion none the less
    • [1] reply
    • No problem. Using a proxy is a good suggestion.
  • [DELETED]
  • 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?
  • 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..
    • [1] reply
    • That all depends on the rewrite base command.

      its definitely htaccess.

      I can look into this for you for a small fee.

Next Topics on Trending Feed

  • 14

    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:         /*