Change WooCommerce product permalink structure
P粉187677012
P粉187677012 2023-07-28 09:58:19
0
1
603
<p>Per my vendor's requirements, they want the local site and the international site to have the same product URL, just different domain names. However, my site is built on WooCommerce, while theirs is using a custom PHP integration. <br /><br />I've spent a few days trying to get it to work via htaccess (I'm no expert) and a custom permalink plugin with no success. <br /><br />I'm not sure if it's possible, but I need the URL structure to be like this: <br /><br />From: https://localhost.za/artnr/ 10616/ to: https://localhost.za/?artnr=10616<br /><br /> I have tried via htaccess file, as I said I am not an expert, also tried using custom Permalinks plugin, but without success. I know I could probably work around this by creating a custom product page, but I'd lose a lot of functionality. </p><p><br /></p>
P粉187677012
P粉187677012

reply all(1)
P粉832490510

Please try using the following in your htaccess file:

RewriteEngine On
RewriteRule ^artnr/(\d+)/?$ /?artnr= [L,QSA]

^artnr/ - This part of the pattern matches the beginning of the URL you want to rewrite.

(\d ) - This is a capturing group that matches one or more digits (in your case the product number) and captures it.

/?$ - This matches an optional slash at the end of the URL.

/?artnr=$1 - This is the replacement part of the rewrite. It replaces the matching URL with the required format, including the query string parameter artnr and its value.

So this should give you the desired URL: https://localhost.za/?artnr=10616

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template