无法使用Laravel 5.6检索查询字符串参数值
我无法从URL检索查询字符串参数值。我的项目正在子目录中运行 请查找有关我的代码的以下详细信息 **请求与结果**无法使用Laravel 5.6检索查询字符串参数值,laravel,laravel-5.6,request.querystring,Laravel,Laravel 5.6,Request.querystring,我无法从URL检索查询字符串参数值。我的项目正在子目录中运行 请查找有关我的代码的以下详细信息 **请求与结果** http://example.com/api/institutes/search?searchValue=hello-世界 .htaccess <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule>
http://example.com/api/institutes/search?searchValue=hello-世界
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
AllowOverride All
</IfModule>
结果:
搜索值:
试试这个:$searchValue=$request->query('searchValue')代码>我已经试过这个了。。。但它仍然不工作,在我将我的应用程序移动到子目录时它已经停止工作了。。。我认为.htaccess
有问题,请尝试转储全局$\u请求
变量,以验证PHP是否具有查询字符串数据。若并没有,那个么问题确实是由于您的服务器配置造成的,和Laravel无关。
public function search(Request $request)
{
try {
$searchValue = 'Search value: ' . $request->searchValue;
return $searchValue;
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}