This is a discussion on mod_rewrite and url depth within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi, I tried to use many variations of RewriteRule but I couldn't get it to work as I'd ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I tried to use many variations of RewriteRule but I couldn't get it to work as I'd like to. The thing is I need to use up to 3 variables in url which looks like: http://www.domain.com/index.php?cat=a&sub=b&item=c I'd like to make it work with urls entered as follows: 1) http://www.domain.com/a/b/c.html pointing to: http://www.domain.com/index.php?cat=a&sub=b&item=c 2) http://www.domain.com/a/b/ http://www.domain.com/a/b http://www.domain.com/a/b.html pointing to: http://www.domain.com/index.php?cat=a&sub=b 3) http://www.domain.com/a http://www.domain.com/a/ http://www.domain.com/a.html pointing to: http://www.domain.com/index.php?cat=a Is it possible to make it work? And if, I will appreciate any hint how to solve this problem. Best regards, PB&J |
|
|||
|
Peanut Butter & Jelly wrote:
> Hi, > > I tried to use many variations of RewriteRule but I couldn't get it to > work as I'd like to. The thing is I need to use up to 3 variables in > url which looks like: > http://www.domain.com/index.php?cat=a&sub=b&item=c > > I'd like to make it work with urls entered as follows: > 1) > http://www.domain.com/a/b/c.html > pointing to: http://www.domain.com/index.php?cat=a&sub=b&item=c > > 2) > http://www.domain.com/a/b/ > http://www.domain.com/a/b > http://www.domain.com/a/b.html > pointing to: http://www.domain.com/index.php?cat=a&sub=b > > 3) > http://www.domain.com/a > http://www.domain.com/a/ > http://www.domain.com/a.html > pointing to: http://www.domain.com/index.php?cat=a > > Is it possible to make it work? And if, I will appreciate any hint how > to solve this problem. Well, if you can accept 'emtpy' GET variables in your script (ie, in the last case indec.php?cat=a&sub=&item= is no trouble, which is the way I usually write: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)/?([^/]*)?/?([^/]*)?/?(\.html)?$ index.php?cat=$1&sub=$2&item=$3 -- Grtz, Rik Wasmus |
|
|||
|
Rik napisał(a):
> Well, if you can accept 'emtpy' GET variables in your script (ie, in > the last case indec.php?cat=a&sub=&item= is no trouble, which is the > way I usually write: > > RewriteCond %{REQUEST_FILENAME} !-d > RewriteCond %{REQUEST_FILENAME} !-f > RewriteRule ^([^/]*)/?([^/]*)?/?([^/]*)?/?(\.html)?$ > index.php?cat=$1&sub=$2&item=$3 > This is exactly what I need! Thank you very much! PB&J |