Re: URL translation like mod_rewrite

From: Date: Tue, 20 Jan 2004 19:15:31 +0000
Subject: Re: URL translation like mod_rewrite
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175183@lists.php.net to get a copy of this message
--- Denzil Kruse <denzilphp@yahoo.com> wrote: > My hosting company won't let me use rewrite rules in my Apache > configuration files, and told me to use "the php header() functions > and a .htaccess file" instead of the rewrite rules. [snip] > What I want to do is have a visitor to my web site enter a userid > after the domain name, and have apache or php grab the userid and > send it to a script. Something like this: > > http://domain.name/denny => > http://domain.name/cgi-bin/script.cgi?userid=denny I don't think you can do this without mod_rewrite, but you can do this: http://example.org/name/denny => http://example.org/cgi-bin/script.cgi?userid=denny Just make name a PHP script, and use the ForceType directive in your .htaccess file: <Files name> ForceType application/x-httpd-php </Files> In this script (name), you can reference $_SERVER['PATH_INFO'] to get the rest of the URL. Parse it, redirect the user, or do whatever you want from there, although it's probably better to just serve the user's request instead of forwarding to another URL. Hope that helps. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/

« previous php.general (#175183) next »