routing

Mod-Rewrite or PHP router?

丶灬走出姿态 提交于 2019-11-28 20:38:39
I am debating routing my requests with one of the two options: Option 1: simple capture route with Mod-Rewrite and funnel written $_GET route to index.php for loading... #default routing RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^blog/([0-9]+)?$ index.php?rt=blog&params=$1 [L,QSA] // ..more custom routes, and then a default route RewriteRule ^([A-Za-z]+)/([A-Za-z]+)/(.*)?$ index.php?rt=$1/$2&params=$3 [L,QSA] Option 2: simply route requests to Front Controller, and create a PHP routing class to handle the routing... #default routing RewriteCond %

Using Linux, how to specify which ethernet interface data is transmitted on

非 Y 不嫁゛ 提交于 2019-11-28 20:35:13
问题 I'm working on a Linux based server system in which there are two network interfaces, both on the same subnet (for now, lets just say they are 172.17.32.10 & 172.17.32.11 ). When I send data to a host on the network, I would like to specify which interface on my server the data is transmitted on. I need to be able to switch from one interface to the other (or maybe even transmit on both) in software (static routing rules won't work for this application). I found a related question in

Asp.Net MVC: How do I get virtual url for the current controller/view?

点点圈 提交于 2019-11-28 20:18:24
问题 Is it possible to get the route/virtual url associated with a controller action or on a view? I saw that Preview 4 added LinkBuilder.BuildUrlFromExpression helper, but it's not very useful if you want to use it on the master, since the controller type can be different. Any thoughts are appreciated. 回答1: I always try to implement the simplest solution that meets the project requirements. As Enstein said, "Make things as simple as possible, but not simpler." Try this. <%: Request.Path %> 回答2:

Accessing the query string in ASP.Net Web Api?

﹥>﹥吖頭↗ 提交于 2019-11-28 20:06:09
I'm using the default template generated by Asp.net Web Api. I'm working with the Get() Part: // GET api/values public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } For some reason the i thought the only thing you had to do to access to query string was just to create an input string variable. So i created one more function (the only change i made) to the default controller generated: public IEnumerable<string> Get(string queryString) { return new string[] { "value3", "value4" }; } I put a break point in both methods but even if i add a query string it always goes

How to detect if rails is at the root url?

你。 提交于 2019-11-28 20:05:20
What I want is seems simple. In my application helper i setup this module ApplicationHelper def isroot if root_url @container = "mainbox" else @container = "maincontainerbox" end end end in my application layout i have this <div id="<%= isroot %>"> How do I find out if my application is at the homepage. if not do something else. To test if you are at the site root: current_page?('/') or, if you defined map.root in your config/routes.rb : current_page?(root_url) 来源: https://stackoverflow.com/questions/1924620/how-to-detect-if-rails-is-at-the-root-url

How Can I Stop ASP.Net MVC Html.ActionLink From Using Existing Route Values?

↘锁芯ラ 提交于 2019-11-28 18:54:21
The website I'm working on has some fairly complicated routing structures and we're experiencing some difficulties working with the routing engine to build URLs the way we need them to be built. We have a search results page that uses RegEx based pattern matching to group several variables into a single route segment (i.e. "www.host.com/{structuralParameters}" can be the following: "www.host.com/variableA-variableB-variableC" - where variables A through C are all optional). This is working for us fine after a bit of work. The problem we are experiencing resolves around an annoying feature of

Laravel 4 - Route::resource vs Route::controller. Which to use?

柔情痞子 提交于 2019-11-28 18:25:51
I understand that a Resource controller can have the following methods index show create edit store update destroy Now suppose I have the following actions which need to be performed in addition to the resource actions: User attempts to log in. Admin wishes to find a user by email / first-name User requests a post by it's slug Are resource controllers useless for the above functionality? If programming an API, I obviously want the index, show, edit,create,destroy... but also the login, find, search etc... Is it possible to route to both types of controller? e.g. Route::group(['prefix' => 'api'

Rails 3 returning a HTTP 406 Not Acceptable?

我怕爱的太早我们不能终老 提交于 2019-11-28 18:09:15
I have the following controller code: def create @admin = Admin.new(params[:admin]) respond_to do |format| if @admin.save redirect_to(@admin, :notice => 'Admin was successfully created.') else render :action => "new" end end end def update @admin = Admin.find(params[:id]) respond_to do |format| if @admin.update_attributes(params[:admin]) redirect_to(admin_admins_path, :notice => 'Admin was successfully updated.') else render :action => "edit" end end end and the following routes: admin_admins GET /admin/admins(.:format) {:action=>"index", :controller=>"admin/admins"} admin_admins POST /admin

Durandal Subrouting (Hottowel)

那年仲夏 提交于 2019-11-28 17:40:00
Basically, I am trying to create a menu inside a menu. So, within a main menu route, there will be a vertical menu with another set of routes. When clicking on the submenu routes, only a part of the page gets updated, and the vertical menu does not reload. I am guessing it would be similar to this KO fiddle http://jsfiddle.net/dPCjM/ , but there would need to another set of "ghost" KO directives in a main route view: <!--ko compose: {model: router.activeItem, afterCompose: router.afterCompose, transition: 'entrance'} --> <!--/ko--> and some other configs on the durandal router... EDIT: And to

Image equivalent of ActionLink in ASP.NET MVC

天大地大妈咪最大 提交于 2019-11-28 17:25:00
In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags? I have a controller action that outputs a dynamically generated JPEG and I wanted to use the same Lambda expressions to link to it as I do HREFs using ActionLink. Alternatively, a helper that just gives the URL to a route (again specified using Lambdas) would also be acceptable. EDIT : I had originally specified that I was using Preview 5, however I see that a Beta has been released. So all-in-all the version number was an unneeded piece of info as I may be upgrading soon :-) Url.Action() will get you the bare