Home How do I check if URL path strictly?
Reply: 2

How do I check if URL path strictly?

Zena Mesfin
Zena Mesfin Published in 2018-02-13 19:03:22Z

In my controller method

I want to know if the URL path is /404 but not /task/id/95404

  redirect_url = request.original_fullpath.include?("404") ? root_path : request.original_url
Sepzo Sonnus
Sepzo Sonnus Reply to 2018-02-13 19:10:35Z

How about trying regex expression to find exact url match? May be try this regex : ^/page$ Here ^ represents starting and $ is the ending of matching string for the url you want to get matched. so just replace the word page with 404. Final regex expression : ^/page$

Gabbar Reply to 2018-02-13 19:13:12Z

In case of url path /404 you will get a id in params hash with value = 404 otherwise you will get value of id is 95404

so here you can also check it like this: -

redirect_url =  params[:id] == 404 ? root_path : request.original_url
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325812 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO