close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Urgent problems with redirects

Thread began 7/26/2012 5:35 pm by Miguel | Last modified 7/27/2012 10:45 am by Miguel | 1550 views | 16 replies

Andrew Read

OK, so I pulled some code from library.php and made a little page to see if the redirects were generating the correct code:

php:
<?php
if (!isset($site_root)) {
  if(isset(
$_SERVER['SCRIPT_FILENAME'])){
      
$WA_DOCUMENT_ROOT $_SERVER['SCRIPT_FILENAME'];
  }
  if(!isset(
$WA_DOCUMENT_ROOT)){
      if(isset(
$_SERVER['PATH_TRANSLATED'])){
          
$WA_DOCUMENT_ROOT =  $_SERVER['PATH_TRANSLATED'];
      }
  }
  if(!isset(
$WA_DOCUMENT_ROOT)){
      
$WA_DOCUMENT_ROOT $_SERVER['DOCUMENT_ROOT'];
  }
  if (
realpath($WA_DOCUMENT_ROOT)) $WA_DOCUMENT_ROOT realpath($WA_DOCUMENT_ROOT); 
  
$WA_DOCUMENT_ROOT str_replace('\\''/'$WA_DOCUMENT_ROOT);
  
$WA_DOCUMENT_ROOT str_replace('//''/'$WA_DOCUMENT_ROOT);
  
$PHPSelf $_SERVER['PHP_SELF'];
  while (
strtolower(basename($WA_DOCUMENT_ROOT)) == strtolower(basename($PHPSelf)) && $WA_DOCUMENT_ROOT != "/" && $WA_DOCUMENT_ROOT!="")  {
      
$WA_DOCUMENT_ROOT dirname($WA_DOCUMENT_ROOT);
      
$PHPSelf dirname($PHPSelf);
  }
  
$site_root $WA_DOCUMENT_ROOT
  
$virtualdir $PHPSelf;
  if (
$site_root == "/" || $site_root == "\\"$site_root "";
  if (
$virtualdir == "/" || $virtualdir == "\\"$virtualdir "";
}


if (!
function_exists('rel2abs') )  {
    function 
rel2abs($rel$base)  {
      
$baseRoot str_replace("\\","/",$GLOBALS['site_root']);
      
$baseRoot str_replace("//","/",$baseRoot); 
      
$base str_replace("\\","/",$base); 
      
$base str_replace("//","/",$base);
      if(
$baseRoot != "" && strpos(strtolower($base), strtolower($baseRoot)) === 0) {
          
$base substr($base,strlen($baseRoot));
          if  (
strpos($base,"/")!==0)  {
            
$base "/" $base;
          }
      }
      
$rel str_replace("\\","/",$rel);
      if(
$baseRoot != "" && strpos(strtolower($rel), strtolower($baseRoot)) === 0) {
          
$rel substr($rel,strlen($baseRoot));
          if  (
strpos($rel,"/")!==0)  {
            
$rel "/" $rel;
          }
      }
      if (
strpos($rel,"/")===|| $base==$rel) {
        return 
$rel;
      }
      
$added false;
      if  (
strpos($base,"/")!==0)  {
        
$base "/" $base;    
        
$added true;
      }
      while (
strpos($rel,"../")===0)  {
        
$base substr($base,0,strrpos($base,"/"));
        
$rel substr($rel,3);
      }
      if (
$added$base substr($base,1);
      if (
$rel!=""){
          
$base $base . ( ($rel == ".") ? "" "/" $rel );
      }
      if (
$GLOBALS['virtualdir']!="" && strpos($base,$GLOBALS['virtualdir']) !== 0)  {
          
$base $GLOBALS['virtualdir'] . $base;
      }
      return 
$base;
    }
}

$GoToPage "filename.php";
if (
function_exists("rel2abs")) {$GoToPage $GoToPage?rel2abs($GoToPage,dirname(__FILE__)):"";}

die(
$GoToPage);
?>

This basically recreates what your code is trying to do with the $GoToPage variable.

Try putting a "/" in front of your filename, it seemed to be required to get this code to work... hopefully that solves it, otherwise the big guys will have to help you tomorrow.

php:
$GoToPage = "/filename.php";

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...