I have this .htaccess code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([\w-]+)/*$ ./index.php?page=$1
This allows one to append a paramater after the forward slash and be used as a $_GET in PHP like so:
URL:
http://www.url.com/home
PHP:
<?php
echo $_GET['home'];
?>
My question is, how do I grab each forward slash and pass that value as a new $_GET for PHP to use? I’m assuming the problem is going to use a regex solution, but since I’m not clued up on regex I can’t figure it out.
Just to clarify by example, I want this:
http://www.url.com/param1/param2/param3
To translate to:
$_GET['param1'];
$_GET['param2'];
$_GET['param3'];
Etc., etc.
Don’t do that inside the rewriting module.
Instead make a simple rewrite to your script and access the raw reqeust ($_SERVER[‘HTTP_REQUEST_URI’]) in there. You get the path that was specified inside the request which you can separate at the slashes by using the explode() function.