I have a single url something like this where 456 is the ID of the category and has been rewritten into a seo friendly url:
http://www.mydomain.com/category/nameofcategory/456.htm
(This is done with this rewrite rule:
RewriteRule ^category/.*/([0-9]+) home/categoryview.php?id=$1 [L,QSA]
I need to keep this intact for all the other categories.)
I'd like to .htaccess redirect my 456 category to a specific product's url:
http://www.mydomain.com/products/nameofproduct/123.htm
If add the following to the .htaccess file
Redirect 301 /category/nameofcategory/456.htm http://www.mydomain.com/products/nameofproduct/123.htm
then the ID is added to the url and returns another product like this.
http://www.mydomain.com/products/nameofproduct/123.htm?456
Is there a way to remove the '?456'
Don't mix mod_rewrite
and mod_alias
rules. Have all rules in mod_rewrite
only.
RewriteEngine On
RewriteRule ^category/[^/]+/456.htm /products/nameofproduct/123.htm? [L,R=301,NC]
RewriteRule ^category/[^/]+/([0-9]+) /home/categoryview.php?id=$1 [L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.