i have form submits data on get
which means, when do:
echo $this->form->create('search', array('type'=>'get', 'url'=> array('controller'=>'searches','action'=>'results'))); echo '<div class="search-box">'; echo $this->form->input('search', array( 'class' => 'search-input', 'placeholder' => 'search domain names', 'label'=>false)); echo $this->form->input('', array( 'class' => 'search-icon', 'label' => false, 'type' => 'submit' )); echo $this->form->end(); ?> i url : example.com/searches/results?search=asdadasdasd
i want frame routes such following url:
example.com/search/asdadasdasd.html
i had @ : http://book.cakephp.org/2.0/en/development/routing.html
i got how extension : http://book.cakephp.org/2.0/en/development/routing.html#file-extensions
but, how search query inside?
thanks
that's not possible cakephp itself, when generating form doesn't know search term since doesn't exist yet, generating such url have done dynamically when submitting form, ie on user side, require javascript.
the easiest thing use server-side url rewriting.
here's example (should work fine in app/webroot/.htaccess), tests query string search key, , uses value redirect in case path of url matches /searches/results (both, path , query string treated case-insensitive):
rewritecond %{query_string} ^search=(.*)$ [nc] rewriterule ^searches/results$ /search/%1.html? [nc,r=302,l] this rewrite urls /searches/results?search=whatever /search/whatever.html.
Comments
Post a Comment