WordPress.org

Support

Support » Localhost Installs » Locked-out loop

Locked-out loop

  • Hi,

    I’ve setup a redirection link by accident on my localhost which directs to an online version which I’m trying to setup, however that online version directs to the localhost, so I’m kind of locked out with no way of logging in to my wp-admin. Is there a way I can manually change or reset this setting on my local files & if so, which file and how?

    HELP ME!

    Nik

Viewing 15 replies - 1 through 15 (of 20 total)
  • How did you setup the redirect? Through the backend

    Yup – in the options section

    Do you have access to the htaccess file? My guess is it would write it there, its that or a php redirect using wp_redirect()

    I do indeed, i’ve got it open now – what should I be looking for?
    I really appreciate your help! Thanks!

    Can you post it here?

    <?php
    
    class Red_Htaccess
    {
    	var $settings;
    	var $items;
    
    	function Red_Htaccess ($settings)
    	{
    		foreach ($settings AS $key => $value)
    			$this->settings[$key] = $value;
    	}
    
    	function encode_from ($url)
    	{
    		return '^'.$this->encode ($url).'$';
    	}
    
    	function encode2nd ($url)
    	{
    		$url = urlencode ($url);
    		$url = str_replace ('%2F', '/', $url);
    		$url = str_replace ('%3A', ':', $url);
    		$url = str_replace ('+', '%20', $url);
    		$url = str_replace ('%24', '$', $url);
    		return $url;
    	}
    
    	function encode ($url)
    	{
    		$url = urlencode ($url);
    		$url = str_replace ('%2F', '/', $url);
    		$url = str_replace ('+', '%20', $url);
    		$url = str_replace ('.', '\\.', $url);
    		return $url;
    	}
    
    	function encode_regex ($url)
    	{
    		$url = str_replace (' ', '%20', $url);
    		$url = str_replace ('.', '\\.', $url);
    		$url = str_replace ('\\.*', '.*', $url);
    		$url = str_replace ('%24', '$', $url);
    		return $url;
    	}
    
    	function add_referrer ($item, $match)
    	{
    		$from = $this->encode_from (ltrim ($item->url, '/'));
    		if ($item->regex)
    			$from = $this->encode_regex (ltrim ($item->url, '/'));
    
    		if (($match->url_from || $match->url_notfrom) && $match->referrer)
    		{
    			$this->items[] = sprintf ('RewriteCond %%{HTTP_REFERER} %s [NC]', ($match->regex ? $this->encode_regex ($match->referrer) : $this->encode_from ($match->referrer)));
    
    			if ($match->url_from)
    			{
    				$to = $this->target ($item->action_type, $match->url_from, $item->action_code, $item->regex);
    				$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
    			}
    
    			if ($match->url_notfrom)
    			{
    				$to = $this->target ($item->action_type, $match->url_notfrom, $item->action_code, $item->regex);
    				$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
    			}
    		}
    	}
    
    	function add_agent ($item, $match)
    	{
    		$from = $this->encode (ltrim ($item->url, '/'));
    		if ($item->regex)
    			$from = $this->encode_regex (ltrim ($item->url, '/'));
    
    		if (($match->url_from || $match->url_notfrom) && $match->user_agent)
    		{
    			$this->items[] = sprintf ('RewriteCond %%{HTTP_USER_AGENT} %s [NC]', ($match->regex ? $this->encode_regex ($match->user_agent) : $this->encode2nd ($match->user_agent)));
    
    			if ($match->url_from)
    			{
    				$to = $this->target ($item->action_type, $match->url_from, $item->action_code, $item->regex);
    				$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
    			}
    
    			if ($match->url_notfrom)
    			{
    				$to = $this->target ($item->action_type, $match->url_notfrom, $item->action_code, $item->regex);
    				$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
    			}
    		}
    	}
    
    	function add_url ($item, $match)
    	{
    		$to   = $this->target ($item->action_type, $match->url, $item->action_code, $item->regex);
    		$from = $this->encode_from (ltrim ($item->url, '/'));
    		if ($item->regex)
    			$from = $this->encode_regex (ltrim ($item->url, '/'));
    
    		if ($to)
    			$this->items[] = sprintf ('RewriteRule %s %s', $from, $to);
    	}
    
    	function action_random ($data, $code, $regex)
    	{
    		// Pick a WP post at random
    		global $wpdb;
    
    		$post = $wpdb->get_var ("SELECT ID FROM {$wpdb->posts} ORDER BY RAND() LIMIT 0,1");
    		$url  = parse_url (get_permalink ($post));
    
    		return sprintf ('%s [R=%d,L]', $this->encode ($url['path']), $code);
    	}
    
    	function action_pass ($data, $code, $regex)
    	{
    		if ($regex)
    			return sprintf ('%s [L]', $this->encode2nd ($data), $code);
    		else
    			return sprintf ('%s [L]', $this->encode2nd ($data), $code);
    	}
    
    	function action_error ($data, $code, $regex)
    	{
    		if ($code == '410')
    			return '/ [G,L]';
    		return '/ [F,L]';
    	}
    
    	function action_url ($data, $code, $regex)
    	{
    		if ($regex)
    			return sprintf ('%s [R=%d,L]', $this->encode2nd ($data), $code);
    		else
    			return sprintf ('%s [R=%d,L]', $this->encode2nd ($data), $code);
    	}
    
    	function target ($action, $data, $code, $regex)
    	{
    		$target = 'action_'.$action;
    
    		if (method_exists ($this, $target))
    			return $this->$target ($data, $code, $regex);
    		return '';
    	}
    
    	function add ($item)
    	{
    		$target = 'add_'.$item->match_type;
    
    		if (method_exists ($this, $target))
    			$this->$target ($item, $item->match);
    	}
    
    	function generate ($name)
    	{
    		// Head of redirection section - do not localize this
    		global $redirection;
    
    		$text[] = '# Created by Redirection Module: '.$name;
    		$text[] = '# '.date ('r');
    		$text[] = '# Redirection '.$redirection->version ().' - http://urbangiraffe.com/plugins/redirection/';
    		$text[] = '';
    
    		// Default blocked files - I can't think of a reason not to block these
    		$text[] = '<Files .htaccess,.svn>';
    		$text[] = 'order allow,deny';
    		$text[] = 'deny from all';
    		$text[] = '</Files>';
    		$text[] = '';
    
    		// PHP options
    		if (isset ($this->settings['error_level']) && $this->settings['error_level'] != 'default')
    			$text[] = 'php_value error_reporting '.($this->settings == 'none' ? '0' : 'E_ALL');
    
    		if (isset ($this->settings['memory_limit']) && $this->settings['memory_limit'] != 0)
    			$text[] = 'php_value memory_limit '.$this->settings['memory_limit'].'M';
    
    		if ($this->settings['allow_ip'] || $this->settings['ban_ip'])
    		{
    			$text[] = '';
    			$text[] = 'order allow,deny';
    			if ($this->settings['ban_ip'])
    			{
    				$ips = array_filter (explode (',', $this->settings['ban_ip']));
    				if (count ($ips) > 0)
    				{
    					foreach ($ips AS $ip)
    						$text[] = 'deny from '.$ip;
    				}
    			}
    
    			if ($this->settings['allow_ip'])
    			{
    				$ips = array_filter (explode (',', $this->settings['allow_ip']));
    				if (count ($ips) > 0)
    				{
    					foreach ($ips AS $ip)
    						$text[] = 'allow from '.$ip;
    				}
    			}
    			else
    				$text[] = 'allow from all';
    		}
    
    		// mod_rewrite section
    		$text[] = '';
    		$text[] = 'Options +FollowSymlinks';
    		$text[] = '';
    		$text[] = '<IfModule mod_rewrite.c>';
    
    		if ($this->settings['canonical'] != 'default')
    		{
    			$text[] = 'RewriteEngine On';
    			$base   = $this->settings['site'];
    			if ($base == '')
    				$base = get_option ('home');
    
    			$parts = parse_url ($base);
    			$base  = str_replace ('www.', '', $parts['host']);
    
    			if ($this->settings['canonical'] == 'nowww')
    			{
    				$text[] = 'RewriteCond %{HTTP_HOST} ^www\.'.str_replace ('.', '\\.', $base).'$ [NC]';
    				$text[] = 'RewriteRule ^(.*)$ http://'.$base.'/$1 [R=301,L]';
    			}
    			else if ($this->settings['canonical'] == 'www')
    			{
    				$text[] = 'RewriteCond %{HTTP_HOST} ^'.str_replace ('.', '\\.', $base).'$ [NC]';
    				$text[] = 'RewriteRule ^(.*)$ http://www.'.$base.'/$1 [R=301,L]';
    			}
    
    			$text[] = '';
    		}
    
    		if ($this->settings['strip_index'] == 'yes')
    		{
    			$text[] = 'RewriteCond %{THE_REQUEST} (.*)index\.(php|htm|html)\ HTTP/';
    			$text[] = 'RewriteRule ^(.*)index\.(php|html|htm)$ $1 [R=301,NC,L]';
    			$text[] = '';
    		}
    
    		// Add redirects
    		if (is_array ($this->items))
    			$text = array_merge ($text, $this->items);
    
    		// End of mod_rewrite
    		$text[] = '</IfModule>';
    		$text[] = '';
    
    		if ($this->settings['raw'])
    			$text[] = $this->settings['raw'];
    
    		// End of redirection section
    		$text[] = '# End of Redirection';
    		$text[] = '';
    
    		$text = implode ("\r\n", $text);
    		$text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    		$text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    		return $text;
    	}
    
    	function save ($filename, $name)
    	{
    		$text = $this->generate ($name);
    
    		// Does the file already exist?
    		if (file_exists ($filename))
    		{
    			$existing = @file_get_contents ($filename);
    
    			// Remove any existing Redirection module
    			$text .= preg_replace ('@# Created by Redirection Module: '.$name.'(.*?)# End of Redirection@s', '', $existing);
    		}
    
    		$file = @fopen ($filename, 'w');
    		if ($file)
    		{
    			$text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    			$text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    
    			fwrite ($file, $text);
    			fclose ($file);
    			return true;
    		}
    
    		return false;
    	}
    }

    [Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    Try removing this

    PLEASE MAKE SURE YOU KEEP A BACKUP OF THIS FILE SO WE CAN ROLL IT BACK IF NEEDED

    // Add redirects
    if (is_array ($this->items))
    $text = array_merge ($text, $this->items);
    
    // End of mod_rewrite
    $text[] = '</IfModule>';
    $text[] = '';
    
    if ($this->settings['raw'])
    $text[] = $this->settings['raw'];
    
    // End of redirection section
    $text[] = '# End of Redirection';
    $text[] = '';
    
    $text = implode ("\r\n", $text);
    $text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    $text = str_replace ("\r\n\r\n\r\n", "\r\n", $text);
    return $text;
    }
    
    function save ($filename, $name)
    {
    $text = $this->generate ($name);
    
    // Does the file already exist?
    if (file_exists ($filename))
    {
    $existing = @file_get_contents ($filename);
    
    // Remove any existing Redirection module
    $text .= preg_replace ('@# Created by Redirection Module: '.$name.'(.*?)# End of Redirection@s', '', $existing);
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Actually this is a giant class, I missed that. Lets just try removing the entire thing and then change your redirects to the proper ones and then reupload the file. That should work.

    Im afraid its still re-directing.. I’ve changed it back to the backup.. Could it be another file?

    What plugin are you using?

    contact form 7
    contact form plugin
    gecka submenu
    iire social lite
    lightbox plus
    nexgen gallery
    options framework
    photomosaic for wordpress
    portfolio post type
    redirection
    social media widget
    synved options
    use any font
    wordpress custom sidebar
    wordpress move

    hmm if we disable redirection plugin that should allow you to get back in but I am not 100 percent if it will delete all your redirects or not. I am really struggling to see why removing the htaccess file doesnt work.

    If you want to try removing your redirection plugin manually that could work. NOTE if you do this you could loose all your redirects. Make sure you backup the db if you try this.

    Do you have more then one htaccess file?

    Ok.. so I removed the code you pasted above from the htaccess files on both my server and the new one I am attempting to move the site to.
    Now the ‘locked out’ redirect loop is broken.
    But the wp admin on my MAMP server is redirecting to the new server which is allowing me to log into WordPress but its a new install and not reading my content.. and I still cant log in to the backend on MAMP.. any thoughts?

    Did you do it in MAMP as well?

    Yeah I did thats whats strange.. I just deleted the one out of MAMP and copied the same one from the new server in.. now its not coming up with the admin screen when i direct to wp-admin but redirects straight to this:

    http://nicolasgaillard.com/wordpress/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%3A81%2Fwp-admin%2F&reauth=1

    before it was allowing me to input the admin credentials and only then redirecting me to
    http://nicolasgaillard.com/wordpress/wp-login.php

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Locked-out loop’ is closed to new replies.
Skip to toolbar