routing

How can I append .html to all my URLs in cakephp?

 ̄綄美尐妖づ 提交于 2019-11-28 04:29:51
问题 I am using cakephp in one of my projects and my client wants the site URLs to end with .html and not the usual friendly urls. I was wondering if its possible in cakephp to do so through any of its routing techniques. Please help. 回答1: That is well documented in the cookbook. UPDATE: http://book.cakephp.org/2.0/en/development/routing.html#file-extensions To handle different file extensions with your routes, you need one extra line in your routes config file: Router::parseExtensions('html',

ASP.NET MVC: url routing vs querystring

会有一股神秘感。 提交于 2019-11-28 04:20:13
I have a page routed like /Comments/Search/3 where i search and display all the comments of the thread "3". I'm adding a sort function (by date, author etc). What is the best way to handle it? /Comments/Search/3/Sort/Author or /Comments/Search/3?sort=author ? How do I automatically handle the querystring sort=author as a parameter in MVC? Thanks I prefer: /Comments/Search/3?sort=author. The querystring is a good place to pass in programmatic parameters, especially if the parameter (like in this case) is not important for SEO purposes. If the parameter had some semantic meaning as a search term

Routing nested resources in Rails 3

眉间皱痕 提交于 2019-11-28 04:08:06
I have a pretty common case for nested routes, I feel like, that looks something like this (in some sort of pseudonotation): '/:username/photos' => Show photos for User.find_by_username '/photos' => Show photos for User.all In a nutshell: I have users. They have photos. I want to be able to show their photos on their page. I also want to be able to show all photos, regardless of the user. I'd like to keep my routes RESTful and using the built-in resource methods feels like the right way to do it. Option 1 for doing this is to have PhotosController#index use a conditional to check which params

ASP.NET MVC Url.Action adds current route values to generated url

江枫思渺然 提交于 2019-11-28 04:04:38
I have seen this question a couple of times here in SO but none of them with any acceptable answer: ASP.NET MVC @Url.Action includes current route data ASP.NET MVC implicitly adds route values Basically I have Controller with an action method called Group, it has an overload that receives no parameters and displays a list of elements and another one that receives an id and displays details for that group. If I do something like this: Url.Action("Group", "Groups"); From the main page of the site (/) it returns an url like this: "mysite.com/Groups/Group" which is alright Now, if the current

Routing to static html page in /public

泄露秘密 提交于 2019-11-28 03:38:39
How can I route /foo to display /public/foo.html in Rails? Arkan You can do this: Add this, into your routes.rb file. match '/foo', :to => redirect('/foo.html') Update In Rails 4, it should use "get", not "match": get '/foo', :to => redirect('/foo.html') thanks Grant Birchmeier This can be done without triggering a redirect. Follow the steps further down to be able to route static files in config/routes.rb as shown in this example: # This route will serve public/index.html at the /login URL # path, and have a URL helper named `login_path`: get "/login", to: static("index.html") # This route

Set Express response headers before redirect

牧云@^-^@ 提交于 2019-11-28 03:17:47
问题 I'm implementing a site login that takes in an email/password combo, retrieves an API token, and returns it to the user to get stored (encrypted) in localStorage. Currently, on successful POSTing to /login , the app redirects the user to the index page, with the token attached as a query, like so (as suggested here): login.post('/', function(req, res) { ...checking password... Auth.getToken(user, function(err, token) { res.redirect('/?token=' + token); }); }); This works fine, but I'd prefer

Is there an standalone PHP routing library? [closed]

别说谁变了你拦得住时间么 提交于 2019-11-28 03:15:50
I'm looking to add some dynamic, REST-esque routing to a PHP application. I'd love to use an existing routing library so I don't have to reinvent the wheel. However, when I look at things like Slim and F3, they all come with things I don't want--like templating and MVC--included. Since I just want routing, I'd end up with a lot of framework code in my application that I don't need. Is there a good library out there that only does routing? Or am I stuck with importing a full framework or reinventing the wheel? Try Klein : Single file, standalone and robust: "klein.php is a lightning fast router

ASP.NET routing: Literal sub-segment between tokens, and route values with a character from the literal sub-segment

微笑、不失礼 提交于 2019-11-28 03:10:18
问题 The reason I'm asking is because IIS protects certain ASP.NET folders, like Bin, App_Data, App_Code, etc. Even if the URL does not map to an actual file system folder IIS rejects a URL with a path segment equal to one of the mentioned names. This means I cannot have a route like this: {controller}/{action}/{id} ... where id can be any string e.g. Catalog/Product/Bin So, instead of disabling this security measure I'm willing to change the route, using a suffix before the id, like these:

express.js - single routing handler for multiple routes in a single line

♀尐吖头ヾ 提交于 2019-11-28 03:03:26
Is there a way to make this on a single function call? var todo = function (req, res){}; app.get("/", todo); app.get("/blabla", todo); app.get("/blablablabla", todo); Something like: app.get("/", "/blabla", "/blablablabla", todo ); I know this is a syntax mess, but just for giving an idea of what I would like to achieve, an array of the routes would be awesome! Anyone know how to do this? I came across this question while looking for the same functionality. @Jonathan Ong mentioned in a comment above that using arrays for paths is deprecated but it is explicitly described in Express 4, and it

Golang: Register multiple routes using range for loop slices/map

穿精又带淫゛_ 提交于 2019-11-28 02:18:34
Consider I have slice of string paths: paths := []string{"/path0", "/path1", "/path2" /*... "/path-n"*/ } // where n is the last path Using package net/http , I want to register handler for this path using for loop with range clause. This is how I do this: for _, path := range paths { http.HandleFunc(path, handler) } // in this case every handler is print the path to the console or to the browser But I ended up with same output which is the last element of slice, so when I go to /path1 , the output is /path-n . Same behavior with other element, always print /path-n . But if I use this: http