dimanche 4 août 2019

.htaccess rewrite rule for a pattern where the URL contains brackets

I have a mod_rewrite rule in place for a clean URL application, however the client is insisting on having brackets in their product name - which ends up in the URL.

Currently using; RewriteRule ^search/([.,'A-Za-z0-9_-]+)/([.,'A-Za-z0-9_-]+)$ /online/product_information.csn?thisCat=$1&thisProd=$2 [QSA,L]

There's probably something more concise that can be used but the above does work until those () appear.

Have tried escaping the brackets within the pattern but nope, doesn't work; RewriteRule ^search/([.,'A-Za-z0-9_-]+)/([.,'A-Za-z0-9_-()]+)$ /online/product_information.csn?thisCat=$1&thisProd=$2 [QSA,L]

Also tried without escaping but that drove the server nuts as expected.

The final URL would be; http://gouda2019.cohesion.co.nz/search/Smallgoods_--_Fish/Salmon_Krokets_(10)

All help appreciated with my thanks in advance.

Aucun commentaire:

Enregistrer un commentaire