• Resolved olygraph

    (@olygraph)


    Hello I want to create a local sandbox for my wordpress and keep the exact same hostname than my hosting server; so when I re-upload all and the database everything stays 1:1.

    I can’t do it via windows hosts file in windows because I need a different port than 80 and don’t want to set wordpress site url to something like mydomain.com:8080

    I’ve tried set it up with FoxyProxy with some regex rules: I.E. redirect mydomain.com -> 192.168.0.x port: 8080

    Eveyrhting works except wordpress: It creates this 301 infinite redirect and final url looks like so:

    http://mydomain.comhttp//mydomain.comhttp//mydomain.com (note the missing colons on the next ones)

    One of the header looks like so:

    
    Status Code:301 Moved Permanently Remote Address:192.168.0.10:80
    
    Referrer Policy:no-referrer-when-downgrade Response Headers view
    
    source Content-Length:2 Content-Type:text/html; charset=UTF-8
    
    Date:Wed, 16 Aug 2017 06:19:11 GMT
    
    Location:http://mydomain.comhttp://mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp//mydomain.comhttp/mydomain.com/
    
    Server:Apache/2.4.18 (Ubuntu) Request Headers view source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
    
    Accept-Encoding:gzip, deflate
    
    Accept-Language:en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4
    
    Cache-Control:no-cache Host:mydomain.comhttp Pragma:no-cache
    
    Proxy-Connection:keep-alive Upgrade-Insecure-Requests:1
    
    User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64)
    
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90
    
    Safari/537.36

    Where can i find the php file that make the redirects so I can try to find what is going on? Thank!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Dion

    (@diondesigns)

    Is there any particular reason you configured Apache to use port 8080 and not port 80? Reconfiguring Apache to use port 80 should solve your problem…

    Thread Starter olygraph

    (@olygraph)

    My ISP blocks port 80 🙁
    + I find that foxyproxy tool very neat for switching back and forth, from whereever i am. ALl works (admin panel, login) Except that index, redirect 🙁

    • This reply was modified 6 years, 8 months ago by olygraph.
    Thread Starter olygraph

    (@olygraph)

    Just found what I was looking for I will investigate tonight why the path is wrong in the canonincal function:

    
    array(8) {
      [0]=>
      array(4) {
        ["file"]=>
        string(69) "/home/mydomain/www/public_html/mydomain.com/wp-includes/canonical.php"
        ["line"]=>
        int(516)
        ["function"]=>
        string(11) "wp_redirect"
        ["args"]=>
        array(2) {
          [0]=>
          &string(37) <strong>"http://mydomain.comhttp/mydomain.com/"</strong>
          [1]=>
          &int(301)
        }
      }
      [1]=>
      array(2) {
        ["function"]=>
        string(18) "redirect_canonical"
        ["args"]=>
        array(1) {
          [0]=>
          &string(0) ""
        }
      }
    • This reply was modified 6 years, 8 months ago by olygraph.
    Thread Starter olygraph

    (@olygraph)

    Found the problem / the solution:

    while using the proxy, the servers variable REQUEST_URI is not the same

    using FoxyProxy, server var ‘REQUEST_URI’ return the full url:

    $_SERVER[‘REQUEST_URI’]
    -> “hxxp://mydomain.com/theurl”

    using windows host file, server var ‘REQUEST_URI’ return just the end of the url:
    $_SERVER[‘REQUEST_URI’]
    -> “/theurl”

    so I added this to the wordpress index.php and everything works #1 😀 :

    
        $_SERVER['REQUEST_URI'] = requesturl_format($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
        
        function requesturl_format($m_host, $m_request){
        	$m_regex = sprintf('#(https?://)(%s)(/.*)#', $m_host);
        
        	if(preg_match( $m_regex, $m_request, $matches)){
        		if(count($matches) == 4){
        
        			$m_host = ($matches[1]);
        			$m_domain = ($matches[2]);
        			$m_url_req = ($matches[3]);
        			return $m_url_req;
        		}
        	}
            return $m_request;
        }
    Dion

    (@diondesigns)

    I’m glad you were able to resolve your issue. That is a fairly serious bug in the proxy program you’re using. If I were you, I would do var_dumps of $_SERVER with the proxy program enabled and disabled, and check whether anything else is incorrect. SCRIPT_NAME, SCRIPT_FILENAME, PHP_SELF, QUERY_STRING and DOCUMENT_ROOT would probably be the most important.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Local domain remap with proxy’ is closed to new replies.