简体   繁体   English

特殊字符laravel路由

[英]special characters laravel routing

I was trying to route to a controller. 我试图路由到控制器。 It works fine everytime, but when there is a (&) in the url, it stops working. 每次都能正常运行,但是当URL中有(&)时,它将停止工作。 I searched on the net and found out (:all) can be used. 我在网上搜索后发现(:all)可以使用。 It worked but when the last url segment has (&) i have to put a slash(/) at the end of the url to make it work. 它起作用了,但是当最后一个URL段具有(&)时,我必须在URL的末尾添加一个斜杠(/)以使其起作用。

ex. 例如 in this 2nd route works correctly and first one does not work 在这第二条路线中正常工作,而第一个则不起作用

Route::get('abc/abc/(:any)', array('uses' => 'abc@abc'));
Route::get('abc/abc/(:all)/do', array('uses' => 'abc@do')); 

ex. 例如 in this none of route works correctly 在这种情况下,路线均无法正常工作

Route::get('abc/abc/(:all)', array('uses' => 'abc@abc'));
Route::get('abc/abc/(:all)/do', array('uses' => 'abc@do'));

ex. 例如 in this both route works correctly 在这两种路线中都可以正常工作

Route::get('abc/abc/(:all)/', array('uses' => 'abc@abc'));
Route::get('abc/abc/(:all)/do', array('uses' => 'abc@do')); 

I just want to find out a way in which i can provide accepted letters in url segment. 我只想找到一种方法,可以在网址段中提供接受的字母。

& is a special character within the context of a URL. &是URL上下文中的特殊字符。 You shouldn't include it in your paths. 您不应将其包括在路径中。 Most likely what is happening is the request parser is looking at the & and then determining that this is a malformed query string ie: some/path/?foo=1&bar=2 when malformed might look like some/path/&foo=1&bar=2 最有可能发生的情况是请求解析器正在查看&,然后确定这是格式错误的查询字符串,即:格式错误时的some / path /?foo = 1&bar = 2可能看起来像some / path /&foo = 1&bar = 2

http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM