url-routing

Codeigniter 2: The requested URL was not found on this server (404) error. CI isn't routing the right way

冷暖自知 提交于 2019-12-02 04:11:55
This is one of the most repeated questions, but I did not get it and had to ask. I use CI 2. I removed index.php from URL by following steps: In config.php I set $config['index_page'] = ''; $config['uri_protocol'] = 'REQUEST_URI'; In routes.php I set $route['default_controller'] = "InterviewController"; here is my .htaccess RewriteEngine on RewriteCond $1 !^(index\.php|img|robots\.txt|css|js|libraries/ckeditor|upload) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] addDefaultCharset UTF-8 I enabled mod_rewrite on the web server. So

Handling slashes on URL parameters

谁都会走 提交于 2019-12-02 04:01:55
I'm running into some issues trying to guess how to handle URLs with parameters on Symfony+Twig. I have this route: <route id="artist.front" path="/artist/{kw}/"> <default key="_controller">App\Web\Controllers\Front::homePage</default> </route> And this code on the Twig template: {% autoescape false %} <a href="{{ path('artist.front',{'kw':a.urlkeyword|url_encode} )}}">{{ a.name }}</a> {% endautoescape %} urlkeyword parameter is passed as is (i.e. not URL encoded previously) both on the entity constructor and on its getter (getURLKeyword). However, when rendering the template I get this HTML

Passing variables before controller URI segment in CodeIgniter

穿精又带淫゛_ 提交于 2019-12-02 02:40:21
I would like to pass some site-wide validated variables before controller segment in URL. Example: Default URL would be: www.mysite.com/controller/method/variable/ Sometimes I'd like to have also URL like this to refer to user created sub-configuration of this site (theme, menus, ...), so user could share this site URL nicely and others would see the site though his custom configurations. www.mysite.com/username/controller/method/variable Here username is custom part of base_url . It should be validated against database and set as session variable to use it later in my controllers and change

Emberjs will not load jquery/javascript, run code when html is inserted in the page

ⅰ亾dé卋堺 提交于 2019-12-02 02:09:26
Help! I'm working on a meaty emberjs/yeoman project that uses multiple hbs templates that can all be routed to from one application.hbs's sidebar. The problem is when I load the page, sometimes the Jquery to make that sidebar collapse will not work while other jquery in that same file does. Sometimes nothing works at all. I'm calling my javascript/jquery from one file called magic.js <body> <!-- build:js scripts/components.js --> <script src="bower_components/jquery/jquery.js"></script> <script src="bower_components/handlebars/handlebars.runtime.js"></script> <script src="bower_components

Ignore first segments in ASP.NET MVC Core routing

我们两清 提交于 2019-12-02 01:45:38
问题 I'm looking for a route definition that is able to match routes like: /segment/xxxx/def /segment/.../xxxx/def /segment/that/can/span/xxxx/def and be able to run the action xxxx with param `def. But this kind of route isn't allowed: [Route("/{*segment}/xxx/{myparam}")] How can it be done? 回答1: You can use a custom IRouter combined with a regular expression to do advanced URL matching such as this. public class EndsWithRoute : IRouter { private readonly Regex urlPattern; private readonly string

URL not accepting alpha numeric parameter - Yii2-app-basic

瘦欲@ 提交于 2019-12-02 01:29:10
问题 As soon, i'm passing 41 in URL. confirm.php prints 41. http://localhost/yii2-app-basic/web/site/confirm/41 But, when i pass "cfeb70c4c627167ee56d6e09b591a3ee" or "41a" in URL, http://localhost/yii2-app-basic/web/site/confirm/41a it shows error NOT FOUND (#404) Page not found. The above error occurred while the Web server was processing your request. Please contact us if you think this is a server error. Thank you. I want to send confirmation id to user to confirm their account. That's why

Ignore first segments in ASP.NET MVC Core routing

岁酱吖の 提交于 2019-12-02 01:28:43
I'm looking for a route definition that is able to match routes like: /segment/xxxx/def /segment/.../xxxx/def /segment/that/can/span/xxxx/def and be able to run the action xxxx with param `def. But this kind of route isn't allowed: [Route("/{*segment}/xxx/{myparam}")] How can it be done? You can use a custom IRouter combined with a regular expression to do advanced URL matching such as this. public class EndsWithRoute : IRouter { private readonly Regex urlPattern; private readonly string controllerName; private readonly string actionName; private readonly string parameterName; private readonly

ASP.NET URL Routing with WebForms - Using the SiteMap

♀尐吖头ヾ 提交于 2019-12-02 00:30:25
I'm trying to use Url Routing within my existing ASP.NET WebForms site. Thanks to: this link , I got it working. Now I'm trying to use a SiteMap along with my routing. I have a page MyReport.aspx. It is in the SiteMap and accessing the page directly, works fine. I've added a route for /report/{param1}/{param2}. I was hoping the sitemap would resolve the route path (MyReport.aspx) instead of /report/{param1}/{param2}, but no dice. I have seen examples of using the SiteMap with MVC , but this makes assumptions about having controllers and such, none of which exist with a standard webform. The

ASP.NET MVC: Restricting access using url

自作多情 提交于 2019-12-01 23:57:59
问题 The URL for the administration section of my website always starts with Admin/ . Is it possible in ASP.NET MVC to restrict access to users by using this part of the URL? Obviously I would keep the [Authorize(Roles = "Administrator")] on appropriate controllers and actions but I wonder if it would be quicker for the application if it can just look at the URL instead of stepping into code. 回答1: Found the answer in Steven Sanderson's book, Pro ASP.NET MVC Framework. Put the following code in

Current URL in ASPCore Middleware?

不羁的心 提交于 2019-12-01 22:26:34
Is there a way I can access the current Requested URL in ASPCore 2.0 Middleware? Is there something I can Inject? Shyju HttpContext object will be passed to the Invoke method of your middleware. You can access the Request property on that. You can use the GetDisplayUrl extension method or GetEncodedUrl extension method. public Task Invoke(HttpContext context) { var url1 =context.Request.GetDisplayUrl(); var url2 = context.Request.GetEncodedUrl(); // Call the next delegate/middleware in the pipeline return this._next(context); } These 2 extension methods are defined in Microsoft.AspNetCore.Http