Redirect url if Contains Query String to new URL and Pass Sting - regex

I have a url https://example.com/registration-free/?member_id=1234&code=0e9236c500453e3c624ca96939f8aabf and this is a conformation link for a subscription process, but I want to locate this to another page and pass the variables, using regex in either htaccess or yoast pro for wordpress
the new page would be https://example.com/registration-step3/?member_id=1234&code=0e9236c500453e3c624ca96939f8aabf
But if someone goes to the page https://example.com/registration-free/ and there is no query string I don't want to redirect them.
Is this possible, so to clarify, if the initial page has no query string it doesn't redirect, but if a query string is present it redirects and passes the variables to the new url, using htacces or regex in wordpress yoast pro

Related

301 redirects - replace a section of the URL

I'm re-working a Woocommerce store, and I need to set up redirects that will send the old URLs, which include category names, to the new URLs, which won't.
EDIT: Both the old and new URLs will contain product/ and the old URL may or may not have a trailing slash.
An example would be:
Old URL: myshop.co.uk/product/category-name/sub-category-name/product-name
New URL: myshop.co.uk/product/product-name
Can anyone tell me what the reg exp would be to achieve this?
Search for (?<=product/)(?:[^/]+/)+(?=[^/]+/?$) and replace with an empty string.

Facebook Graph API add extra parameter to login url

is there any way to get back my users to the current page after they login and redirect to my callback url? for example my current page url is:
https://mydomain.test/post1
then my callback url is:
https:/mydomain.test/callback.php
I tried to add extra parameter to login url but got an error because of the Valid OAuth Redirect URIs url match. my url is dynamic so I need a way to set parameters that changes and start from there.

Redirect url regex

I need to make some redirections in a wordpress site with "Redirections" plugin that allows only regex. Exactly i need to transform this url model:
http://example.com/cat1/subcat2/subcat3/subcat4/bar/this%20is%20page?start=130
To:
http://example.com/bar/this-is-page
Only if "bar" is in url. Anyway, last segment can be like this /page.
How can i obtain that result?

Wordpress Redirection with Regex and keep querysting data

I am trying to have new redirect rules using regex, and need to reuse some of the data in the new URL format.
Old URL structure:
http://www.example.com/shop/checkout/order-received/DATA1?key=DATA2
NEW URL Structure:
http://www.example.com/?page_id=12874&order-received=DATA1&key=DATA2
How should I do that?
Thanks!

Extract URL value if has sku in the url

I am having a url like
http://192.168.1.5/wpp/base/product/sku/4t4tsdg
if sku word is present in the url i need need to extract the value 4t4tsdg using regex. i am using in wordpress
i tried using /product/sku/(.*/?)$ but unable to get it
php code i used in wordpress
add_rewrite_rule('/product/sku/(.*/?)$', 'index.php?product_sku=$matches[1]', 'top');