I am unable to retrieve the query string parameter value from the URL. My project is running in sub-directory.
Please find the following details about my code
**Request & result **
http://example.com/api/institutes/search?searchValue=hello-world
.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>
Route
Route::get('/institutes/search', 'InstituteController@search');
Controller:
public function search(Request $request)
{
try {
$searchValue = 'Search value: ' . $request->searchValue;
return $searchValue;
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
}
Result: Search value: