Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a conditional route

how can I create a conditional route that work for the following:

http://site.com/1vcs1YUf1Z

Where 1vcs1YUf1Z is a UID.

Is there a way I can add a routing option to the end of my route file that says if the following condition is met (10 characters trailing the first / and that's it) then to route to the following and pass that as the UID?

Thanks

like image 841
AnApprentice Avatar asked Apr 18 '26 02:04

AnApprentice


1 Answers

get 'projects/:uid' => 'controller#action',
  :constraints => { :uid => /^[0-9a-z]{10}$/i }
like image 198
J-_-L Avatar answered Apr 20 '26 17:04

J-_-L



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!