mod_rewrite and url depth

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-17-2006
Peanut Butter & Jelly
 
Posts: n/a
Default mod_rewrite and url depth

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
  #2 (permalink)  
Old 08-19-2006
Rik
 
Posts: n/a
Default Re: mod_rewrite and url depth

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


  #3 (permalink)  
Old 08-19-2006
Peanut Butter & Jelly
 
Posts: n/a
Default Re: mod_rewrite and url depth

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:10 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0