I usually set these up like so:
RewriteRule folder/(.*)/ path_to_file.php?aff=$1
So for 2 variables:
RewriteRule folder/(.*)/(.*)/ path_to_file.php?aff=$1&extra=$2
if you want to allow it to be accessinble without the trailing slash then add that rule after above like so:
RewriteRule folder/(.*)/(.*)/ path_to_file.php?aff=$1&extra=$2
RewriteRule folder/(.*)/(.*) path_to_file.php?aff=$1&extra=$2
- RewriteRule folder/(.*)/(.*)/ path_to_file.php?aff=$1&extra=$2
- RewriteRule folder/(.*)/(.*) path_to_file.php?aff=$1&extra=$2
if you are using an undefined number of extra variables you can pass them together like so
folder/123/dino/news/
- the folder/123/ part is obvious and then you have a remainder that will all belong to the variable extra - this part:
dino/news/
you can use this method for passing multiples that are unfined rules by setting up your page to access that portion using the REQUEST_URI and splitting it into an array like so:
$attributes = explode("/", $_REQUEST[extra]);
$attributes[0] = dino
$attributes[1] = news
- $attributes = explode("/", $_REQUEST[extra]);
-
- $attributes[0] = dino
- $attributes[1] = news
I had to use this method for creating Rules for dynamic subdomains using Wildcard DNS.
May come in handy for those of you developing larger applications using dynamic subdomains.
There is a big difference from creating a social networking site that creates dynamic urls like:
domain.com/member/miker/
to a url like:
miker.domain.com
in which case .htaccess only goes so far and it is time to bring out the URI.