Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Confusion :D

         

supermanjnk

1:47 am on Oct 18, 2006 (gmt 0)

10+ Year Member



RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]*)/?$ index.php?sect=$1 [nc]
#
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?sect=$1&cat=$2 [nc]
#
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]*)/([^/]*)/page([0-9]*).php/?$ index.php?sect=$1&cat=$2&page=$3
#
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?sect=$1&cat=$2&page=$3 [nc]
#
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*).php/?$ index.php?sect=$1&cat=$2&page=$3 [nc]

This is my current htaccess

I would like to add another url friendly section to my site seperate from the main section
What I want is for if the url is

mydomain.com/* to redirect to index.php?sect=$1
mydomain.com/*/* to redirect to index.php?sect=$1&cat=$2
but if it's mydomain.com/bob index.php?sect=bob
and mydomain.com/bob/* to redirect to index.php?sect=$1&othercat=$2

so bascially Every secion will rewrite to either:
'index.php?sect=$1', 'index.php?sect=$1&cat=$2' or 'index.php?sect=$1&cat=$2&page=$3'
Unless Sect = Bob in which case I want:
'index.php?sect=$1', 'index.php?sect=$1&cat=$2' or index.php?sect=$1&othercat=$2&otherpage=$3

Also, Does anyone have a good Regex tutorial? I've been able to get the basics from what I've found but I'm still a bit confused (especially when it comes to matching things)