Redirect script

From: Date: Fri, 10 Nov 2000 20:42:16 +0000
Subject: Redirect script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-24550@lists.php.net to get a copy of this message
Alrighty....here's a mess to consider. I have PHP 4 on Apache on Linux and this is what I want to do. The directories on the website are huge...massive path names. We want people to be able to type an address in that will bring them to the end of the tree without having to type the whole thing in. e.g. http://www.hostname.org/nicenshort --> http://www.hostname.org/big/log/path/name/that/no_one_wants.html Yes I know about the Apache Redirect in httpd.conf, but the people that need to create the short links don't have webadmin status, and need to create them by adding these links manually. I know about the REQUEST_URI environment variable, and it seems to me that a simple script like this might work.... where the datafile is in the format: shortnice http://www.hostname.org/huge/big/long/bad/directory/tree ================== $request = getenv("REQUEST_URI"); $length = strlen($request); if($datafile = fopen("redirect.txt", "r")) { while(!feof($datafile)) { $line = fgets($datafile, 255); if (substr($line, 0, $length) = $request) { $result = substr($line, $length, 255); open a window, create frames, set up navigation bar, and invoke the $result html file. } } fclose($datafile); } ================================ So here is my question. . . I make a symbolic link for each of the lines found in redirect.txt to my script. ln -s myscript.php link1 ln -s myscript.php link2 ln -s myscript.php link3 ln -s myscript.php link4 ...etc. When the php script is called, it isn't executed, the source code is displayed on the browser screen. If I call the php script directly, with the php extension (www.hostname.org/myscript.php) it runs fine and works. what to do? Thanks Dan

« previous php.general (#24550) next »