I'm transferring my old site to a new shopify domain.
What I'm looking for is to redirect from here
to there:
I've created this regex (?<=\/)\w+$
and checked in : it matches the «brand».
I checked the .htaccess
in
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/golf
RewriteRule "(?<=\/)\w+$" "/$1" [R=301,L]
and the output URL is:
://url-old/collections/
The output contains the old URL without the brand AND the new URL, but $1
is not defined or used.
I've tried and looked a lot. I hope, somebody can help me out.
I'm transferring my old site to a new shopify domain.
What I'm looking for is to redirect from here
https://www.url-old.com/golf/shoes/white/winter/brand
to there:
https://url-old.com/collections/brand
I've created this regex (?<=\/)\w+$
and checked in https://regexr.com : it matches the «brand».
I checked the .htaccess
in https://htaccess.madewithlove.com
https://www.url-old.com/golf/shoes/white/winter/brand
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/golf
RewriteRule "(?<=\/)\w+$" "https://url-old.com/collections/$1" [R=301,L]
and the output URL is:
https://www.url-old.com/golf/shoes/white/winter/https://url-old.com/collections/
The output contains the old URL without the brand AND the new URL, but $1
is not defined or used.
I've tried and looked a lot. I hope, somebody can help me out.
Share Improve this question edited Feb 6 at 17:42 MrWhite 45.8k8 gold badges64 silver badges87 bronze badges asked Feb 6 at 12:44 Thomas HenkeThomas Henke 91 silver badge2 bronze badges 5 |1 Answer
Reset to default 0try
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/golf/shoes/white/winter/(.*)$
RewriteRule ^ /collections/%1 [R=301,L]
This Should correctly redirect https://www.url-old.com/golf/shoes/white/winter/brand to https://url-old.com/collections/brand.
/collections/$1
? – C3roe Commented Feb 6 at 12:53golf
and the brand,RewriteRule ^golf/.*/([^/]+)$ /collections/$1 [R=301,L]
should basically already do the job, htaccess.madewithlove.com?share=f718a017-d0d8-4c1c-86a7-5828b84… (No RewriteCond, because the RewriteRule itself is perfectly capable of applying that part of the condition to the URL path via its own pattern.) – C3roe Commented Feb 6 at 13:04