Forum Moderators: phranque
This works with
mydomain.com/whatever/section/category/id/
I would like to get rid of the whatever so that I just have:
mydomain.com/section/category/id/
but everything i try ends up breaking
Any sugestions would be great.
I guess you're having problems because the rule will rewrite anything ending in slash, including URLs you don't want rewritten.
Two ways to fix this are to prevent rewriting if the requested file actually exists, or to explicitly prevent certain subdirectories from being rewritten:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/$ /file.php?sect=$1 [L]
#
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)/$ /file.php?sect=$1&cat=$2 [L]
#
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /file.php?sect=$1&cat=$2&id=$3 [L]
RewriteCond $1 !^images
RewriteCond $1 !^shared
RewriteRule ^([^/]*)/$ /file.php?sect=$1 [L]
#
RewriteCond $1 !^foo/images
RewriteCond $1 !^bar/scripts
RewriteCond $1 !^widgets/green
RewriteRule ^([^/]*)/([^/]*)/$ /file.php?sect=$1&cat=$2 [L]
#
RewriteCond $1 !^random/foo/images
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /file.php?sect=$1&cat=$2&id=$3 [L]
Many more variations and alternate implementations are possible, depending on your directory and file structure, so the above stand only as examples.
Jim
[edited by: jdMorgan at 7:08 pm (utc) on Oct. 6, 2006]