简体   繁体   中英

Multi Level Pretty URL for E-Commerce Products In htaccess

Updated Version I am developing an E-commerce portal where the products need to be shown with a pretty url and also under categories.

My Current Link: http://abcd.xyz/products.php?pro_tag=1221212112 (FAKE LINK)

My Goal: http://abcd.xyz/products/1221212112 (FAKE LINK)

My Current HTACCESS CODE. (Made it with the help of other Stackoverflow Suggestions) :

RewriteEngine On
RewriteBase /
RewriteRule ^products/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$1 [QSA,NC,L]
RewriteRule ^products/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$2&ctg=$1 [QSA,NC,L]

Figured out the problem: 'pro_tag' isn't being fetched. Need help to fix that.

Try with:

RewriteEngine On
RewriteBase /
RewriteRule ^products/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$1 [QSA,NC,L]
RewriteRule ^products/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$2&ctg=$1 [QSA,NC,L]

I add a ctg variable...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM