Extract URL value if has sku in the url - regex

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

Related

Remove last part of URL with regex

I have lot of URL links that looks like:
https://www.example.com/category/product_name?product_rewrite=product_name
I am trying to redirect them to:
https://www.example.com/category/product_name
I have a module in Prestashop where I can put regex for redirect old to new URL.
I am trying with:
OLD URL: https://www.example.com/(.)\?product_rewrite=(.)
New URL: https://www.exampe.com/(.*)\
Unfortunately above is not working and can not find why - because module is not working properly or because I am giving wrong data.

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

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?

Django url pattern doesn't match

I am using new Django 1.8 app to learn Django.
I am stumped as to how to get this my simple url to be resolved by urls.py
I create the url in another view as:
<a href="/photoview/{{photo.id}}/"}>
I can successfully pass this url to the browser as:
http://localhost:8000/photoview/300/
I am expecting that this url can be matched by the urls.py expression:
url('r^photoview/(?P<id>\d+)/$', views.photoview),
But this is not working. I have tried variations of this but none have worked so far, such as:
url('r^photoview/(?P<id>[0-9]+)/$', views.photoview),
I get this message in browser when it fails to match
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/photoview/300/
Using the URLconf defined in asset.urls, Django tried these URL patterns, in this order:
^admin/
^$ [name='index']
^time/$
^about/$
^accounts/$
^photos/$
^tags/$
^users/$
r^photoview/(?P<id>\d+)/$
^static\/photos\/(?P<path>.*)$
The current URL, photoview/300/, didn't match any of these.
Appreciate any help getting this to work.
you have url('r^photoview/(?P<id>\d+)/$', views.photoview),
you want url(r'^photoview/(?P<id>\d+)/$', views.photoview),
(Note the r is in front of the string, not the first character)
As noted in docs.djangoproject.com/en/1.8/topics/http/urls,
The 'r' in front of each regular expression string is optional but
recommended. It tells Python that a string is “raw” – that nothing in
the string should be escaped
Also note that you should use a friendly name in your url definition (e.g. photoview) and then use {% url 'photoview' photo.id %} in your template instead of hardcoding the URL pattern.

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,'&')