Hello all...
i've found a lot of useful informations on this great website, and i 've come to develop my own htaccess file for my needs.
i still need to know if there is any flaws in it
MY NEEDS:
*** i want to be able to access this kind of url :
www.domain.com/docs/ => www.domain.com/index.php?pg=docs
www.domain.com/docs/123/ => www.domain.com/index.php?pg=docs&entity=123
www.domain.com/docs/123/edit/ => www.domain.com/index.php?pg=docs&entity=123&action=edit
*** i need to have hidden dirs and putting php files that can still be accessed in a regular way (no rewriting)
eg : www.domain.com/hiddendir/admin.php => www.domain.com/hiddendir/admin.php
*** the ability to add dynamic variables at the various depth (the [QSA] tag is here for that
www.domain.com/docs/?style=red => www.domain.com/index.php?pg=docs&style=red
www.domain.com/docs/123/?layout=horizontal&foo=bar => www.domain.com/index.php?pg=docs&layout=horizontal&foo=bar
HERE IS the code.
Thanks a lot in advance for any advice or thought about this, i'm not really a specialist, but this kind of work on my website, so maybe it's good...
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/ /index.php?pg=$1&entity=$2&action=$3 [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/ /index.php?pg=$1&entity=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/ /index.php?pg=$1 [QSA]
Thanks again for all the help !