Laravel 4 : Route to localhost/controller/action

If you are looking for a more automated routing, this would be the Laravel 4 way: Route: Route::controller(‘users’, ‘UsersController’); Controller (in this case UsersController.php): public function getIndex() { // routed from GET request to /users } public function getProfile() { // routed from GET request to /users/profile } public function postProfile() { // routed from … Read more

For Next.js Dynamic Routes, it is possible to combine a string with a [slug]?

While Next.js doesn’t provide built-in support for partial dynamic routes (like something-[slug]), you can work around it by setting up an actual dynamic route and use rewrites to map the incoming URL (in the format you want) to that route. For instance, you could setup a dynamic route under /pages/something/[slug].jsx, then configure a rewrites rule … Read more

Routing URLs in PHP

Use mod_rewrite to route everything to a single index.php file. Then check the variable in $_SERVER[‘REQUEST_URI’] within this file to dispatch to the required handler. This configuration will enable mod_rewrite, if it’s installed: DirectorySlash Off Options FollowSymLinks Indexes DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^.*$ – … Read more

AngularJS: can’t get html5 mode urls with ui-route $state

This configuration has worked for many of our Apache users using html5mode and ui-router. <VirtualHost *:80> ServerName my-app DocumentRoot /path/to/app <Directory /path/to/app> RewriteEngine on # Don’t rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.html … Read more

Client-side Javascript app – url routing with no hash tag

In Ember.js (version 1.0.0rc3) this can be accomplished by using the Ember.js location API: App.Router.reopen({ location: ‘history’ }); And then setting the web server to redirect traffic to the Ember application. To give a concrete example here is a basic Apache .htaccess file redirecting traffic to the Ember application located in index.html: RewriteEngine on RewriteCond … Read more

Difference between $state.transitionTo() and $state.go() in Angular ui-router

Are you referring to the AngularUI Router? If so, the wiki specifies the differences: $state.go(to [, toParams] [, options]) Returns a Promise representing the state of the transition. Convenience method for transitioning to a new state. $state.go calls $state.transitionTo internally but automatically sets options to { location: true, inherit: true, relative: $state.$current, notify: true }. … Read more

Route with Two optional parameters in MVC3 not working

You’re missing the parameters in your route config. In order to make this work with different parameters optional (as in Phil Haack’s post), you need to define multiple routes routes.MapRoute(“UserDetail-WithStatus”, “UserDetail/{id}/{inSaveAction}/{status}”, new { controller = “Admin”, action = “UserDetail”, // nothing optional } ); routes.MapRoute(“UserDetail-WithoutStatus”, “UserDetail/{id}/{inSaveAction}”, new { controller = “Admin”, action = “UserDetail”, // … Read more