I have some problems with RewritingUrl with Symfony (2.8) My goal is to redirect the url without having them change in the browser bar.
I need this so that the URL can have a user-readable form and be accessible.
The URL is also used on the form, so the data is submitted on the form ?param=data
In any case, Symfony's internal routing doesn't seem to work quite well (or maybe I missed some things, but I searched up and down all day for this without finding the right answer)
Without frame, in .htaccess If the user went to
www.website.com/search/London/15
I would redirect them to
www.website.com/searchEngine?search_action[city]=London&search_action[radius]=15
Without changing the browser url, so SearchEngine nevers appears with a simple RewriteRule
RewriteRule ^search/(.*)/(.*)$ /searchEngine?search_action[city]=$1&search_action[radius]=$2 [L]
Symfony ( .htaccess /web forlder, ?),
www.website.com/search/London/15 Symfony 404
, Symfony / , , URL- SearchEngin .htaccess
SearchEngine www.website.com/SearchEngine?search_action[city]=London&search_action[radius]=15
.htaccess Symfony , R RewriteRule
RewriteRule ^search/(.*)/(.*)$ /searchEngine?search_action[city]=$1&search_action[radius]=$2 [R,L]
, URL- , SearchEngine.
, Symfony , /search/London/15
SearchEngine?search_action[city]=London&search_action[radius]=15
Url?
- , ?
Routing
, URL , .
routing.yml
research_action:
path: /SearchEngine
defaults: { _controller: "MySearchBundle:Search:search" }
SearchController: searchAction
public function searchAction(Request $request)
{
$form = $this->createForm('MySearchBundle\Form\Type\SearchType',null);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid())
{
}
return $this->render('SomeDefaultPage.html.twig');
}
.htaccess
...
//Basic Symfony Routing stuff
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule search/(.*)/(.*)$ /SearchEngine?search_action[city]=$1&search_action[radius]=$2 [R=301,L]
RewriteRule .? %{ENV:BASE}/app.php [L]
.....