I'm not an expert on mod_rewrite, but this is an example of how I put together .htaccess for the Image Flair site:
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)/(.*)\.png$ imageFlair.php?mode=$1&userid=$2 [L] RewriteRule ^(.*)\.png$ imageFlair.php?userid=$1 [L] </IfModule>
These are mainly cards:
MODE / USERID.png →? ImageFlair.php mode = MODE & = USERID
and
USERID.png → imageFlair.php? UserID = USERID
You should be able to adapt this to your needs, but you may have several problems:
- If you want to use "names" rather than identifiers in your URL, you will need to modify PHP to accept the names.
- You may have a problem with the / Page and / ModuleType conflicts if you also want to include more parameters in the parameter using the page, if you cannot collect a regular expression that can determine what is.
Going to the list of URLs you want, this should work, although I will not argue that this is the best or only way to do this :-)
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)/(.*)/(.*)$ index.php?m=$1&categoryID=$2&productID=$3 [L] RewriteRule ^(.*)/(.*)$ index.php?m=$1&categoryID=$2 [L] RewriteRule ^(.*)$ index.php?Page=$1 [L] </IfModule>
As suggested, you may want to replace. * to [^ /] +, but I had problems with inconsistencies when I did this, and there was no time to troubleshoot, so YMMV :-)
source share