Good Search URLs

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.

/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?

+3
source share
6 answers

you should definitely read this guide:

basics:

  • mysql_real_escape_string()
  • Alpha/Num
  • +
  • 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. , , .

+4

, , , /blah. , .

javascript, GET , .

, javascript , "search/"+escapedSearchTerm. , , javascript , , .

.

+2

API ?

Javascript jQuery .

0

JavaScript . . search.php?q=blah, URL-, search.html?searchterm=blah /search/blah/, .

, URL. , , , mod_rewrite, .

0

, , onclick() action - /search/blah/, URL-.

0

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.

0
source

Source: https://habr.com/ru/post/1789822/


All Articles