url-routing

$_GET and URL Rewriting for PHP

▼魔方 西西 提交于 2019-11-27 11:46:34
问题 How does URL rewriting affect the $_GET parameter for PHP? Say I have a URL like http://example.com/index.php?p=contact and I use $_GET['p'] to tell index.php to serve the contact page. If I use a rewrite rule that converts the URL to http://example.com/contact , will $_GET['p'] still work as expected? If it does, could you elaborate on why it works? If not, what strategies could be used to solve the problem so that the page will work both with and without the rewrite? 回答1: Yes, that will

Clearing URL hash

感情迁移 提交于 2019-11-27 11:43:56
问题 Visit stackoverflow.com/#_=_ and window.location.hash evaluates to #_=_ . Fine. Now execute window.location.hash = '' to clear the hash, and the URL becomes stackoverflow.com/# . (Notice the trailing # .) Why is the # in window.location.hash inconsistently included or excluded? How can the # be removed from the URL without reloading the page? (MDN says [the hash is] the part of the URL that follows the # symbol, including the # symbol. but that is not true for in the case of an empty hash.)

RegEx to match stuff between parentheses

核能气质少年 提交于 2019-11-27 11:33:38
I'm having a tough time getting this to work. I have a string like: something/([0-9])/([a-z]) And I need regex or a method of getting each match between the parentheses and return an array of matches like: [ [0-9], [a-z] ] The regex I'm using is /\((.+)\)/ which does seem to match the right thing if there is only one set of parenthesis. How can I get an array like above using any RegExp method in JavaScript? I need to return just that array because the returned items in the array will be looped through to create a URL routing scheme. You need to make your regex pattern 'non-greedy' by adding a

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

邮差的信 提交于 2019-11-27 11:29:32
I'm working on a new client-side only app with the latest version of Ember.js. There is a single PHP page which builds the scripts, css, template files, etc. and delivers it all into index.php. I'm using an htaccess directive so that all requests are rewritten to /index.php. The PHP is only there to conveniently package the Javascript, as far as I'm concerned. Currently, routes in the browser look like this and work just fine. /#/about /#/favorites /#/etc /#/posts/5/edit However, I would like them to look like this - which do not work just fine. /about /favorites /etc /posts/5/edit The exact

Add a trailing slash at the end of each url?

和自甴很熟 提交于 2019-11-27 11:08:01
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 as so: routes.MapRoute("register", "register/", new {controller = "Users", action = "Register"} );

Dynamic URL -> Controller mapping for routes in Rails

谁都会走 提交于 2019-11-27 10:58:39
问题 I would like to be able to map URLs to Controllers dynamically based on information in my database. I'm looking to do something functionally equivalent to this (assuming a View model): map.route '/:view_name', :controller => lambda { View.find_by_name(params[:view_name]).controller } Others have suggested dynamically rebuilding the routes, but this won't work for me as there may be thousands of Views that map to the same Controller 回答1: This question is old, but I found it interesting. A

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

↘锁芯ラ 提交于 2019-11-27 10:49:34
In AngularJS, I see sometimes we use $state.transitionTo() and sometimes we use $state.go() . Can anyone tell me how they differ and when one should be used over the other? 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 } . This allows you to easily use

Get current url in Angular [duplicate]

梦想的初衷 提交于 2019-11-27 10:24:03
问题 This question already has an answer here: How to get current route 32 answers How can I get the current url in Angular 4? I've searched the web for it a lot, but am unable to find solution. app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { RouterModule, Router } from '@angular/Router'; import { AppComponent } from './app.component'; import { TestComponent } from './test/test.component'; import { OtherComponent } from '.

Angular ui router - Redirection doesn't work at all

你离开我真会死。 提交于 2019-11-27 09:17:41
I'm using ui.router for routing in my Angular app. There is a typical login scenario, where I'm redirecting a user to the login url if he's not logged in. Without the ui.router library, this worked fine using $routeChangeStart event combined with $location.path . Now, I'm using the $stateChangeStart event, combined with $state.go , and the nothing works! It also sends my browser into an infinite loop. I read from other sources that this is a known bug, and none of the suggested solutions work for me. Moreover, $location.path too doesn't redirect to the login page. This is how I've configured

Using routes in Express-js

眉间皱痕 提交于 2019-11-27 09:10:41
问题 So I'm starting to use Node.js. I saw the video with Ryan Dahl on Nodejs.org and heard he recommended Express-js for websites. I downloaded the latest version of Express, and began to code. I have a fully fledged static view up on /, but as soon as I try sending parameters, I get errors like this: Cannot GET /wiki I tried following the guide on expressjs.com but the way one uses routes has changed in the latest version, which makes the guide unusable. Guide: app.get('/users/:id?', function