Re: URL rewriting...anybody done this?

From: Date: Fri, 16 Jan 2004 01:14:05 +0000
Subject: Re: URL rewriting...anybody done this?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174746@lists.php.net to get a copy of this message
On Friday, January 16, 2004, at 11:04 AM, Ryan A wrote:
RewriteEngine On Options +FollowSymlinks RewriteRule ^tt/(.*).php tt.php?id=$1 This is my php page: <?php echo "Ok,we are in tt.php<br>"; if(isset($_GET["id"])){echo "Got \$_GET[id]<br>";}else{echo "No \$_GET[id]<br>";} print_r($_GET); print_r($_REQUEST); print_r($_GET['id']); ?>
Ryan, This would have been solved a lot quicker on a list dedicated to Apache. I tested this, and it works: .htaccess --- #Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^tt.php/(.*) tt.php?id=$1 RewriteRule ^tt.php/(.*).php tt.php?id=$1 </IfModule> --- With this tt.php file: --- <h1>tt.php</h1> <pre> <? print_r($_GET); ?> </pre> --- A few notes: - I commented out the Options line because *my* Apache set-up doesn't need it, but yours may (it depends on the httpd.conf file). - I've tested the above with the following URLs: - http://indentclients.com/tests/ryan/tt/45.php - http://indentclients.com/tests/ryan/tt/45 - http://indentclients.com/tests/ryan/tt/45/ - http://indentclients.com/tests/ryan/tt.php/45.php - http://indentclients.com/tests/ryan/tt.php/45 - http://indentclients.com/tests/ryan/tt.php/45/ In all cases, it output: Array (
    	[id] => 45
) - it also works for me without the <IfModule...> and </IfModule> lines - if this STILL doesn't work, it's more than likely that your host does not allow mod_rewrite, doesn't allow you total freedom in your .htaccess file, etc etc -- find a new host. Justin French

« previous php.general (#174746) next »