Forum Moderators: phranque
For instance, I would like to make:
somesite.com/dir1/dir2/dir3/dir4/
go to
index.php?dir1=$1&dir2=$2&dir3=$3&dir4=$4
and something like:
somesite.com/dir1/dir2
go to
index.php?dir1=$1&dir2=$2
All with the same rule. Is it possible to make a rewrite that can take any number of directories and add them to a query string? I know I could manual make 100 different rules for each dir combo, but there has to be a better way.
If not, maybe someone can just tell me how I can get:
somesite.com/dir1
and/or:
somesite.com/dir1/
to turn into
index.php?dir1=$1
And the second rule would be:
somesite.com/dir1/dir2
and/or:
somesite.com/dir1/dir2/
to
index.php?dir1=$1&dir2=$2
All while still letting any images or stylesheets in the "/images/" dir get through!
Here are some of the rule I have been trying:
Code:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^/(.*)/(.*)$ index.php?dir1=$1&dir2=$2 RewriteRule ^([A-Za-z0-9-]+)/images/([A-Za-z0-9-]+)$ /images/$2 [L] RewriteRule ^([A-Za-z0-9-]+)/default.css$ default.css [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?dir=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)?$ index.php?dir=$1 [L]
RewriteRule ^/(.+) drains.php?drains=$1 [L]
RewriteRule ^dir/(.+)/(.+) index.php?dir1=$1&dir2=$2 [nc]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php?dir=$1 [L,QSA]
Any help would be appreciated! :D
Jim