|
Home > Archive > Apache Server configuration support > December 2007 > mod_rewrite dynamic directories
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mod_rewrite dynamic directories
|
|
| cmgmyr 2007-12-07, 1:33 pm |
| 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
| |
| lihao0129@gmail.com 2007-12-07, 7:26 pm |
| On Dec 7, 12:37 pm, cmgmyr <cmg...@gmail.com> 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
| |
| cmgmyr 2007-12-08, 2:59 pm |
| On Dec 7, 4:15 pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
> On Dec 7, 12:37 pm, cmgmyr <cmg...@gmail.com> wrote:
>
>
>
>
> 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
Thanks for the reply!
I had to alter your code a little bit, here is what I have now:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^([^/\.]+)/?$ store/index.php?kiosk=$1 [L,PT]
RewriteRule ^([^/]*)/([^/]*)$ store/$2?kiosk=$1 [QSA,L,PT]
Now, the virtual directories work 100%, but when I go to the root of
the site, or any of the files in the root the CSS and the images do
not come up. How can I adjust this code so that it doesn't effect the
root files?
Thanks,
-Chris
| |
| lihao0129@gmail.com 2007-12-08, 2:59 pm |
| On Dec 8, 12:30 pm, cmgmyr <cmg...@gmail.com> wrote:
> On Dec 7, 4:15 pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
> Thanks for the reply!
>
> I had to alter your code a little bit, here is what I have now:
> RewriteEngine on
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-F
> RewriteRule ^([^/\.]+)/?$ store/index.php?kiosk=$1 [L,PT]
> RewriteRule ^([^/]*)/([^/]*)$ store/$2?kiosk=$1 [QSA,L,PT]
>
> Now, the virtual directories work 100%, but when I go to the root of
> the site, or any of the files in the root the CSS and the images do
> not come up. How can I adjust this code so that it doesn't effect the
> root files?
Can your check error.log or access.log, and see what happened to these
image/CSS file?? my wild guess is the second rule, you probably need
to make it more specific. i.e. if you want to redirect only php files,
then:
RewriteRule ^([^/]*)/([^/]*\.php)$ store/$2?kiosk=$1 [QSA,L,PT]
Regards,
XC
> Thanks,
> -Chris- Hide quoted text -
>
> - Show quoted text -
| |
| cmgmyr 2007-12-09, 7:24 pm |
| On Dec 8, 3:25 pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
> On Dec 8, 12:30 pm, cmgmyr <cmg...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Can your check error.log or access.log, and see what happened to these
> image/CSS file?? my wild guess is the second rule, you probably need
> to make it more specific. i.e. if you want to redirect only php files,
> then:
>
> RewriteRule ^([^/]*)/([^/]*\.php)$ store/$2?kiosk=$1 [QSA,L,PT]
>
> Regards,
> XC
>
>
>
>
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Hey Thanks! That worked great! The only problem that I have now is
that I have an "admin" directory to control the website. When I try
and go her and log in I get redirected as if "admin" was a virtual
directory. What can I add to stop this from happening? I though the
"RewriteCond %{REQUEST_FILENAME} !-d" stopped this from happening?
Thanks,
-Chris
| |
| cmgmyr 2007-12-11, 1:26 pm |
| On Dec 9, 3:04 pm, cmgmyr <cmg...@gmail.com> wrote:
> On Dec 8, 3:25 pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hey Thanks! That worked great! The only problem that I have now is
> that I have an "admin" directory to control the website. When I try
> and go her and log in I get redirected as if "admin" was a virtual
> directory. What can I add to stop this from happening? I though the
> "RewriteCond %{REQUEST_FILENAME} !-d" stopped this from happening?
>
> Thanks,
> -Chris- Hide quoted text -
>
> - Show quoted text -
I just added another .htaccess file in the "admin" folder with
"RewriteEngine off" in it and it took care of it. Thanks for the help!
|
|
|
|
|