简体   繁体   English

Laravel中的URL参数格式

[英]URL parameter format in Laravel

I hve a Laravel 5.2 application. 我有一个Laravel 5.2应用程序。 I have a route where I receive a parameter called ID by GET method. 我有一条路由,通过GET方法接收称为ID的参数。 The format of the ID is giving me some problems, an ID is formed like: ID的格式给我一些问题,ID的格式如下:

Somecharacter%40otherThing.somethingelse

Sending the ID as above gives me File not found in the browser, but, if I delete the % or the . 如上所述发送ID给我,在浏览器中File not found ,但是,如果我删除%. everything works fine, its like they cannot coexist in the URL. 一切正常,就像它们不能在URL中共存一样。 The route in Routes.php file is: Routes.php文件中的路由为:

Route::get('generateFile/{action}/{id?}',array('as'=>'generateFile','uses'=>'MyController@generate'))->where('id', '(.*)'); 

So, I'm starting to believe that I have to modify the where clause in the route, but I don't know what exactly should I put to makeit accept a parameter as I said before. 因此,我开始相信我必须修改路由中的where子句,但是我不知道我应该怎样使它接受一个参数,就像我之前说的那样。 Thanks in advanced! 提前致谢!

Just pass id with encryption urlencode 只需传递带有加密urlencode的ID

urlencode(\Crypt::encrypt(id));

get the id back using 使用返回ID

urldecode(\Crypt::decrypt(id));

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

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