url-routing

Dynamic routes with Rails 3

╄→尐↘猪︶ㄣ 提交于 2019-12-17 15:36:46
问题 I have a task to develop a rails application following the model for routing. I need to have PageController and Page model. Page urls must be like /contacts, /shipping, /some_page . Also i need have CatalogController and Category model. Categories urls must be like /laptops, /smartphones/android . And it will be ProductsController and Product model, urls of products must be line /laptops/toshiba_sattelite_l605 , /smartphones/android/htc_magic I understand that this problem can be solved by

Laravel 4 : Route to localhost/controller/action

柔情痞子 提交于 2019-12-17 12:41:53
问题 I'm more or less new to Laravel 4. I've never used routes before but normally what I'm used to is url/controller/action and then the backend routing for me. I've read the documentation for routes and controllers a few times as well as read through some tutorials and so, I'm trying to figure out how to get this to work without writing a route for every controller and action. I tried something like Route::get('{controller}/{action}', function($controller, $action = 'index'){ return $controller.

Laravel 4 : Route to localhost/controller/action

♀尐吖头ヾ 提交于 2019-12-17 12:41:05
问题 I'm more or less new to Laravel 4. I've never used routes before but normally what I'm used to is url/controller/action and then the backend routing for me. I've read the documentation for routes and controllers a few times as well as read through some tutorials and so, I'm trying to figure out how to get this to work without writing a route for every controller and action. I tried something like Route::get('{controller}/{action}', function($controller, $action = 'index'){ return $controller.

Simulate file structure with PHP

試著忘記壹切 提交于 2019-12-17 10:57:14
问题 I'm running PHP on a shared Apache web server. I can edit the .htaccess file. I'm trying to simulate a file file structure that is not actually there. For example, I would like for the URL: www.Stackoverflow.com/jimwiggly to actually display www.StackOverflow.com/index.php?name=jimwiggly I got halfway there by editing my .htaccess file as per the instructions in this post: PHP: Serve pages without .php files in file structure: RewriteEngine on RewriteRule ^jimwiggly$ index.php?name=jimwiggly

MVC role-based routing

别等时光非礼了梦想. 提交于 2019-12-17 10:32:29
问题 I have a project with 2 areas /Admin and /User. Admin's default route is /Admin/Home/Index and user's default route is /User/Home/Index . Is it possible to implement routing to make their home URL to look like /Profile/Index but to show content from /Admin/Home/Index for admins and /User/Home/Index for users? upd Finally find out how to do it context.MapRoute( "Admin", "Profile/{action}", new { area = AreaName, controller = "Home", action = "Index" }, new { RoleConstraint = new Core

Add a trailing slash at the end of each url?

寵の児 提交于 2019-12-17 10:21:19
问题 I have a little problem here. I need to add a trailing slash at the end of each url in the site I'm working on. I defined all the links inside the site to have a trailing slash like so: <a href="/register/">Register</a> While this works fine there's still one tiny issue: it's with the generated urls that come from calling RedirectToAction(). For example: return RedirectToAction("Register", "Users"); Will cause the url to change to /register with no trailing slash. I modified my routing system

Why do I need to use http.StripPrefix to access my static files?

你。 提交于 2019-12-17 03:38:49
问题 main.go package main import ( "net/http" ) func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.ListenAndServe(":8080", nil) } Directory structure: %GOPATH%/src/project_name/main.go %GOPATH%/src/project_name/static/..files and folders .. Even after reading the documentation I have trouble understanding what exactly http.StripPrefix does here. 1) Why can't I access localhost:8080/static if I remove http.StripPrefix ? 2) What URL maps to

Is it possible to get the controller and the action (NOT THEIR NAME!!) based on the url?

ぐ巨炮叔叔 提交于 2019-12-14 04:00:09
问题 I have found a dozens of threads about getting the name of the controller and method based on the url, I managed that just as well. Can I get the MethodInfo of the method based on their name automatically from the MVC engine, or do I have to do Type.GetType("Namespace.Controllers."+cname+"Controller").GetMethod(mname) ? Which is not so nice, since how do I know the namespace in a framework class? How do I know if the default naming patterns are being observed, or is there a different config

Customizing URLs with prefix in laravel

泄露秘密 提交于 2019-12-13 16:15:35
问题 I have this html: <ul> <li><a href="index.php/Page1">Page 01</a></ <li><a href="index.php/Page2">Page 02</a></li> <li><a href="index.php/Page3">Page 03</a></li> </ul> As you can see, I need to use the index.php/ prefix in all links due to the server of my university (I can't change it). The way is done above, it works fine to go straightfoward from home to any page, but if I try to access a page from another page, I get a wrong URL and Can't access the page: Examples: Home http://localhost

How I can dynamically generate url ( for generating xls report )?

三世轮回 提交于 2019-12-13 06:05:58
问题 Hello! I have this trouble: I'm searching reports by date and in html view everything is alright, BUT when I'm rendering xls view error appear, because it didn't receive params, so I need to pass them in URL for xls link_to generator. My controller: def show @website = Website.find(params[:id]) if params[:report] && params[:report][:start_date] && params[:report][:end_date] #search_by_created_at @performance_reports = @website.performance_reports.where("created_at between ? and ?", params[