routing

How to determine if an arbitrary URL matches a defined route

自古美人都是妖i 提交于 2020-01-19 05:16:07
问题 How can I tell if a string matches a particular named route? I have a route like this: routes.MapRoute( "FindYourNewRental", "find-your-new-rental/{market}/{community}.html", new { controller = "FindYourNewRental", action = "Community" } ); string url = "http://www.website.com/find-your-new-rental/northerncalifornia/sacramento.html" How can I programmatically tell if the 'url' string matches that route? Something like this: // matches url with the named route "FindYourNewRental" if

Routes with Dash `-` Instead of Underscore `_` in Ruby on Rails

删除回忆录丶 提交于 2020-01-19 04:44:49
问题 I want my urls to use dash - instead of underscore _ as word separators. For example controller/my-action instead of controller/my_action . I'm surprised about two things: Google et al. continue to distinguish them. That Ruby on Rails doesn't have a simple, global configuration parameter to map - to _ in the routing. Or does it? The best solution I've is to use :as or a named route. My idea is to modify the Rails routing to check for that global config and change - to _ before dispatching to

Routes with Dash `-` Instead of Underscore `_` in Ruby on Rails

时光总嘲笑我的痴心妄想 提交于 2020-01-19 04:44:24
问题 I want my urls to use dash - instead of underscore _ as word separators. For example controller/my-action instead of controller/my_action . I'm surprised about two things: Google et al. continue to distinguish them. That Ruby on Rails doesn't have a simple, global configuration parameter to map - to _ in the routing. Or does it? The best solution I've is to use :as or a named route. My idea is to modify the Rails routing to check for that global config and change - to _ before dispatching to

Laravel - Using (:any?) wildcard for ALL routes?

五迷三道 提交于 2020-01-18 21:37:27
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

Laravel - Using (:any?) wildcard for ALL routes?

拟墨画扇 提交于 2020-01-18 21:37:08
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

Laravel - Using (:any?) wildcard for ALL routes?

拥有回忆 提交于 2020-01-18 21:36:10
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

How can I find out the current route in Rails?

眉间皱痕 提交于 2020-01-18 11:08:32
问题 I need to know the current route in a filter in Rails. How can I find out what it is? I'm doing REST resources, and see no named routes. 回答1: To find out URI: current_uri = request.env['PATH_INFO'] # If you are browsing http://example.com/my/test/path, # then above line will yield current_uri as "/my/test/path" To find out the route i.e. controller, action and params: path = ActionController::Routing::Routes.recognize_path "/your/path/here/" # ...or newer Rails versions: # path = Rails

htaccess and MVC routing

牧云@^-^@ 提交于 2020-01-17 05:03:42
问题 Well i started coding a mini MVC base that I can just use on client websites, which also uses the same type of router class as CakePHP. I currently have the url display like this: http://localhost/mvc/index.php?page=blog/viewall Which gets the controller and tells it the function, just like CakePHP index(), view(), and so on. Now, I'm not sure how I can make the url look like this with .htaccess http://localhost/mvc/blog/viewall I was trying to add this in the .htaccess file: RewriteRule ^(.*

Url routing errors in php in codeigniter

时光怂恿深爱的人放手 提交于 2020-01-16 19:40:40
问题 My login form on front page is displayed, but when it posts to other pages, the post does not happen. THe problem is that the url is like: http://sitename/users/action which is a 404 not found url. But when i hard code the path to controller, (that is, stop using base_url + "/users/action" and use base_url + "/system/application/controllers/users/action") it starts working. How can i fix this problem? 回答1: Are you using .htaccess to hide index.php ? If so, you need to take that into account

Url routing errors in php in codeigniter

☆樱花仙子☆ 提交于 2020-01-16 19:38:27
问题 My login form on front page is displayed, but when it posts to other pages, the post does not happen. THe problem is that the url is like: http://sitename/users/action which is a 404 not found url. But when i hard code the path to controller, (that is, stop using base_url + "/users/action" and use base_url + "/system/application/controllers/users/action") it starts working. How can i fix this problem? 回答1: Are you using .htaccess to hide index.php ? If so, you need to take that into account