mod_rewrite dynamic directories

mod_rewrite dynamic directories

am 07.12.2007 18:37:21 von cmgmyr

Hello all,

Ihave a site that has dynamic kiosk stores and I can't seem to get
everything to work how I want it to.

1. I need url.com/kiosk_name going to url.com/store/index.php?
kiosk=kiosk_name (which I have that so far).
2. I need url.com/kiosk_name/products.php going to url.com/store/
products.php?kiosk=kiosk_name
3. This also needs to handle a query sting...url.com/kiosk_name/
products.php?product=1 going to url.com/store/products.php?
kiosk=kiosk_name&product=1

Here is what I have so far:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^([^/\.]+)/([^/\.]+)?$ $2?kiosk=$1
RewriteRule ^([^/\.]+)/?$ store/index.php?kiosk=$1 [L]

I know I'm doing something wrong and I'm sure some other things need
to be added. What should this be?

Thanks,
-Chris

Re: mod_rewrite dynamic directories

am 07.12.2007 22:15:46 von lihao0129

On Dec 7, 12:37 pm, cmgmyr wrote:
> Hello all,
>
> Ihave a site that has dynamic kiosk stores and I can't seem to get
> everything to work how I want it to.
>
> 1. I need url.com/kiosk_name going to url.com/store/index.php?
> kiosk=kiosk_name (which I have that so far).
> 2. I need url.com/kiosk_name/products.php going to url.com/store/
> products.php?kiosk=kiosk_name
> 3. This also needs to handle a query sting...url.com/kiosk_name/
> products.php?product=1 going to url.com/store/products.php?
> kiosk=kiosk_name&product=1
>

how about the following rules:

RewriteEngine on
RewriteRule ^/([^/]*)$ /store/index.php?kiosk=$1
[L,PT]
RewriteRule ^/([^/]*)/([^/]*)$ /store/$2?kiosk=$1
[QSA,L,PT]

(untested)

XC