Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

MVC web application (like Ruby on Rails, ASP.NET MVC, etc) uses routes to map an arbitrary URL to a specific controller/action.

For example

http://example.com/foo/bar/23

Might pass an id 23 to controller foo, action bar.

Unusual URLs could also be mapped

Given controller places and intended action list, we can use routes to allow this URL:

http://example.com/my/places
32975 questions
94
votes
5 answers

AngularJS - How can I do a redirect with a full page load?

I want to do a redirect that does a full page reload so that the cookies from my web server are refreshed when the page loads. window.location = "/#/Next" and window.location.href = "/#/Next" don't work, they do an Angular route which does not hit…
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
93
votes
2 answers

Rails routing to handle multiple domains on single application

I've been unable to find a workable solution to this problem, despite several similar questions here and elsewhere. It seems likely that this question hasn't been answered for Rails 3, so here goes: I have an application that currently allows users…
Aaron Vegh
  • 5,217
  • 7
  • 48
  • 75
92
votes
4 answers

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

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…
pduey
  • 3,706
  • 2
  • 23
  • 31
90
votes
19 answers

My Routes are Returning a 404, How can I Fix Them?

I've just started learning the Laravel framework and I'm having an issue with routing. The only route that's working is the default home route that's attached to Laravel out of the box. I'm using WAMP on Windows and it uses PHP 5.4.3, and Apache…
JasonMortonNZ
  • 3,752
  • 8
  • 34
  • 56
89
votes
6 answers

In express how do I redirect a user to an external url?

I have a payment system using node.js and braintree, when the payment is successful I want to send the user to the back end. My back end is setup elsewhere. I have tried res.writeHead(301, {Location: 'http://app.example.io'} ); res.end(); So…
Michael Joseph Aubry
  • 12,282
  • 16
  • 70
  • 135
89
votes
11 answers

htaccess redirect for Angular routes

I have an angular application with several routes, such as: site.com/ site.com/page site.com/page/4 Using angular's html5 routing mode, these resolve correctly when you click links to them from within the application, but of course are 404 errors…
Lucas Penney
  • 2,624
  • 4
  • 27
  • 36
87
votes
3 answers

Angularjs, passing scope between routes

I have a situation with a form that stretches over several pages (might not be ideal, but that is how it is). I'd like to have one scope for the entire form that gets filled in as you go along, so that if the user goes back and forth between steps…
Erik Honn
  • 7,576
  • 5
  • 33
  • 42
86
votes
2 answers

Adding Hash parameter in the URL Rails Routes

How to add a hash parameter in link_to. I need to generate a URL something like this.. /p/generate/#sometext This is how my code looks now. link_to "Click",my_path How to add the hash parameter to my routes method. Now for the answer When I posted…
Manjunath Manoharan
  • 4,567
  • 6
  • 28
  • 43
83
votes
4 answers

Draw path between two points using Google Maps Android API v2

Google changed its map API for Android and introduced API V2. The previous codes for drawing path are not working with API V2. I have managed to draw a path with API V2. I had searched a lot for the solution but did not find any answer. So I am…
81
votes
3 answers

Why do routes with a dot in a parameter fail to match?

I've got an route for my users like /iGEL/contributions, which works fine. But now a user registered with a name like 'A.and.B.', and now the route fails to match, since the name contains dots. My route: get "/:user/contributions" =>…
iGEL
  • 16,540
  • 11
  • 60
  • 74
80
votes
6 answers

ASP.NET MVC Routing Via Method Attributes

In the StackOverflow Podcast #54, Jeff mentions they register their URL routes in the StackOverflow codebase via an attribute above the method that handles the route. Sounds like a good concept (with the caveat that Phil Haack brought up regarding…
TorgoGuy
  • 1,316
  • 1
  • 9
  • 10
80
votes
7 answers

Routing to controller with optional parameters

I'd like to create a route that takes a required ID, and optional start and end dates ('Ymd'). If dates are omitted, they fall back to a default. (Say last 30 days) and call a controller....lets say…
Steve
  • 801
  • 1
  • 6
  • 3
79
votes
10 answers

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

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…
qwerty
  • 5,166
  • 17
  • 56
  • 77
77
votes
3 answers

Routing to static html page in /public

How can I route /foo to display /public/foo.html in Rails?
Aen Tan
  • 3,305
  • 6
  • 32
  • 52
76
votes
3 answers

When to use "client-side routing" or "server-side routing"?

I'm a little bit confused about this, and I feel slightly stupid asking this question, but I want to understand it. So, say I'm working with a client side web framework, like Backbone, Angular or Durandal. This framework includes routing. But I of…
tomet
  • 2,416
  • 6
  • 30
  • 45