Redirect url regex - 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?

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.

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

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

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');

ColdFusion - Capture Last Parameter

From my understanding #CGI.PATH_INFO# will grab my url path. But in my application I only want to grab the last parameter in my urls. So say I have the following urls:
http://www.mysite.com/page.cfm?id=13213&var=23&htm
http://www.mysite.com/page.cfm?id=232213&var=33&doc
http://www.mysite.com/page.cfm?id=454543&var=64&xls
How can I grab the htm, doc, and xls from the url?
You can use the ListLast function
ListLast(cgi.query_string,'&')

Django. How to redirect to url with fragment identifier

For example in some cases after POST or GET request I want to redirect user not only to specific page, but to a specific part of page. What would be better: implement this in Django(reconstruct redirect url?) or implement this in javascript?
Why would you want to do it in JS? If you're redirecting to a different page already, just add #whatever to the redirect URL to go direct to the anchor.