We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Hi everyone,


    Here’s the updated code for IIS 5+ friendly URL

    You can add this code to manager/includes/documentparser.class.inc.php at line 886:

    // IIS friendly url fix 
    if($this->config['friendly_urls']==1 && strpos($_SERVER['SERVER_SOFTWARE'],'Microsoft-IIS')!==false) {
    	$url = $_SERVER['QUERY_STRING'];
    	if(substr($url,0,3)=='404') {
    		$qp = parse_url(str_replace($this->config['site_url'],'',substr($url,4)));
    		if($qp['query']) {
    			parse_str($qp['query'],$qv);
    			foreach($qv as $n=>$v) $_REQUEST[$n]=$_GET[$n]=$v;
    		}
    		$_REQUEST['q'] = $_GET['q'] = $qp['path'];
    	}
    }
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 32963
      • 1,732 Posts
      Ok today I found a bug when doing postbacks with the IIS Friendly URLs. Here’s the fix:

      1) Point both your custom 404 and 405 pages to the /index.php page
      2) replace the above code with this one:

      // IIS friendly url fix 
      if($this->config['friendly_urls']==1 && strpos($_SERVER['SERVER_SOFTWARE'],'Microsoft-IIS')!==false) {
      	$url = $_SERVER['QUERY_STRING'];
      	$err = substr($url,0,3);
      	if($err=='404'||$err=='405') {
      		$_SERVER['QUERY_STRING']=$qp['query'];
      		$qp = parse_url(str_replace($this->config['site_url'],'',substr($url,4)));
      		if(!empty($qp['query'])) {
      			parse_str($qp['query'],$qv);
      			foreach($qv as $n=>$v) $_REQUEST[$n]=$_GET[$n]=$v;
      		}
      		$_REQUEST['q'] = $_GET['q'] = $qp['path'];
      	}
      }



      Here’s also another solution for those who need true URL rewrite for IIS servers
      http://www.isapirewrite.com
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.