I have a form that submits to a search page. I can process the MOD_REWRITE files on the back, but I want to know how best to get the search results page in a good format.
Is it better to get a submit form and then redirect to a nicer URL structure. In the following example, the user is searching blah.
blah
/search.html?searchterm=blah
What redirects to
/search/blah/
Or can I (my preferred option) do this using javascript (or jQuery) somehow after the user clicks the submit button?
you should definitely read this guide:
http://matthewjamestaylor.com/blog/how-to-post-forms-to-clean-rewritten-urls
basics:
mysql_real_escape_string()
+
SELECT MATCH AGAINST
IN BOLEAN MODE
LIKE
mod_rewrite
RewriteRule ^search/([^/\.]+)$ search.php?q=$1
PS: PHP , , , preg_replace ereg_replace, , ; stopwords regex, , : foo-bar. , , .
PHP
preg_replace
ereg_replace
stopwords
regex
, , , /blah. , .
javascript, GET , .
, javascript , "search/"+escapedSearchTerm. , , javascript , , .
"search/"+escapedSearchTerm
.
API ?
Javascript jQuery .
JavaScript . . search.php?q=blah, URL-, search.html?searchterm=blah /search/blah/, .
search.php?q=blah
search.html?searchterm=blah
, URL. , , , mod_rewrite, .
, , onclick() action - /search/blah/, URL-.
onclick()
action
GET . URL-/search? Q = blah - , mod_rewrite, .
JavaScript / jQuery is not suitable for this. This would add an additional client delay for something that needs to be processed on the server side (rewrite), especially if the request is correctly constructed in the search form.
Source: https://habr.com/ru/post/1789822/More articles:ASP.NET MVC 3 - Client Validation with a Money Field - asp.net-mvc-3WCF service stops to create threads - multithreadingCapture Modal Dialog Object Using MSHTML / IExplorer - c #Limitations of the C ++ Preprocessor Directive - c ++T4MVC Html.ActionLink или Html.RouteLink - как добавить цель - t4mvcHow to check HttpListener () using localhost? - c #Проблема с вставкой данных в таблицу - objective-cWhat design pattern should be used to model Person-Role relationships? - javaPythonic way to conditionally iterate over items in a list - pythonEffective definition of set boundaries - language-agnosticAll Articles