Forum Moderators: phranque
Would like to get the following URLs to rewrite to /find/productinfo.php?prodID=12 (or 20 or 60).
www.example.com/find/12/
www.example.com/find/20/
www.example.com/find/60/
I put the following rule in the .htaccess file in the "find" folder.
RewriteEngine on
RewriteRule ^find/([0-9][0-9])/$ /find/productinfo.php?prodID=$1
It's not working at the moment. Any tips?
Help much appreciated!
Therefore, "find/" should not appear in the RewriteRule's pattern in /find/.htaccess, it should only appear in the substitution.
You can shorten "[0-9][0-9]" to "[0-9]{2}" to match two digits only, to "[0-9]{1,3}" to match one to three digits, or to "[0-9]+" to match one or more digits.
For efficiency, always use an [L] flag unless you know you have a good reason not to.
Try:
RewriteRule ^([0-9]{2})/$ /find/productinfo.php?prodID=$1 [L]
Jim
Next, make sure that anyone requesting a URL with
/find/productinfo.php?prodID=nnn in it, is redirected to the new URL for that content, otherwise those old URLs could be indexed as Duplicates. This redirect should also force the correct domain name within the same redirect.