Help with mod_rewrite
Posted: Sun Nov 30, 2008 2:42 am
Hi all ...
I have a site I am working on that has a URL format of one of the following ...
index.php?cat=x
index.php?cat=x&sub=y
index.php?cat=x&sub=y&page=z
I've never used mod_rewrite before, and it's being more of a challenge than I expected, but I got ... ... and that seems to do the job.
However, I also want to optionally append &mode=edit on any level, which when applied through mod_rewrite would look something like ...
/x/edit
/x/y/edit
/x/y/z/edit
... or even ...
/x/edit.php
/x/y/edit.php
/x/y/z/edit.php
I've tried many variations on the rewrites I have so far, but I cant seem to find a way to match edit and not sub or page.
Any help would be greatly appreciated.
Cheers
I have a site I am working on that has a URL format of one of the following ...
index.php?cat=x
index.php?cat=x&sub=y
index.php?cat=x&sub=y&page=z
I've never used mod_rewrite before, and it's being more of a challenge than I expected, but I got ...
Code: Select all
RewriteRule ^([^/\.]+)/?$ /showGet.php?cat=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /showGet.php?cat=$1&sub=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /showGet.php?cat=$1&sub=$2&page=$3 [L]However, I also want to optionally append &mode=edit on any level, which when applied through mod_rewrite would look something like ...
/x/edit
/x/y/edit
/x/y/z/edit
... or even ...
/x/edit.php
/x/y/edit.php
/x/y/z/edit.php
I've tried many variations on the rewrites I have so far, but I cant seem to find a way to match edit and not sub or page.
Any help would be greatly appreciated.
Cheers