ColdFusion - Capture Last Parameter - coldfusion

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

Related

Django url having %20 issues

One of my urls in url.py goes like this is like this
path('<str:subject>/<str:agglevel>/<str:cust_cd>/',views.Customer.as_view())
cust_cd takes value from UI. cust_cd is basically customer name which is a string value.
Url works fine for single words for cust_cd. Ex:Google,Gmail etc. But when I give words with spaces like Ex:You tube I get 404 error. It says you%20tube not found. Am not able to figure out how to configure url so that it accepts space characters.
in your urls.py file
instead of
<str:cust_cd>
try this
<slug:cust_cd>
for more information check out this link: https://docs.djangoproject.com/en/3.0/topics/http/urls/#path-converters

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?

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

Regex Url conf Django

I am trying to get the following setup up going.
Flatpages: Where all my static sites are (like: about, contact,..)
Dynamic Pages:
Here I am trying to link from one of the Flatpages to a start site:
the regex in the url conf of this startsite I tried was:
(r'^myapp/start/(\d+)/$', 'mysite.views.def_that_should_just_show_hello_world'),
In the views I had:
def def_that_should_just_show_hello_world(request):
return HttpResponse("Hello experiment world")
If I go to
/myapp/ I get 404: No FlatPage matches the given query.
/myapp/start/ I get 404: No FlatPage matches the given query.
/myapp/start/1 I get
Exception Type: TypeError
def_that_should_just_show_hello_world takes exactly 1 argument (2 given)
I thought with this setup I would get "Hello experiment world" on EVERY page.
Where did I go wrong?
I dont understand the multiple sites approach in regexs.
What would I have to do to print hello world on all these sites?
And then, what would I have to do to display 1 image on all of these sites?
Thanks a lot for the help!
You regular expression has a matching group in it - the (\d+) bit.
This requires one or more numeric characters to appear at the end of the url for that view. If you do not include the number at the end, this regular expression will not match the url. (url matching works like any other regular expression matching).
When you do include the number, eg. /myapp/start/1 you then have another problem. Because there is a matching group, the part of the url in the brackets will be passed as another argument to your view. Views are always passed the request as their first parameter but in this case the '1' matched by the (\d+) is provided as a second argument. This is why you are hetting the TypeError in this case.
Django's documentation has a lot of information on how url dispatching works, read that through and see if that makes sense!
from your_app_name import views
from django.conf.urls import url
urlpatterns = [
url(r'^$',views.method_name,name ='index'),
path('admin/', admin.site.urls),