Web Hosting Talk







View Full Version : mod rewrite


ak55
12-10-2004, 09:32 PM
hey,

i need help with mod rewrite

i wan to make it so that whenever i do

site.com/content/<PARAMETERS>

it sends the parameters to the content.php?params

how could this be done?

gogocode
12-10-2004, 11:39 PM
http://httpd.apache.org/docs/misc/rewriteguide.html

Loon
12-11-2004, 07:25 AM
RewriteRule ^content/(.*) content.php?params=$1

eg: site.com/content/monkeys goes to site.com/content.php?params=monkeys :)

astellar
12-12-2004, 02:11 PM
For apache 2.x:
in /content/.htaccess file:

RewriteEngine on
RewriteRule ^(.*) /content.php?rwr=$1 [NC,L]


if you need more than one parameter passed to content.php you must use php code somthing like:

$rwr_ar = explode("/", $rwr);
foreach($rwr_ar as $dummy => $var)
{
$rw_var = explode("_", $var);
if (!empty($rw_var[0])) $GLOBALS[$rw_var[0]] = (int)$rw_var[1];
}