Rewriting a GET URL

I use codeigniter to create a search page. I would like to rewrite the GET URL to work with CI.

Example

http://mysite.com/en/search?search=widgets

becomes

http://mysite.com/en/search/widgets

I thought I could do it in route.php, but it doesn't seem to grab the material after. "So now I think I'm rewriting in .htaccess. Is this a good idea? What will be the rewriting rule?

+3
source share
3 answers

You should use only the CI routing protocol. Anyway, if you want to use .htaccess, this is:

RewriteEngine On
RewriteRule ^en/search/([a-z]+)  /en/search?search=$1 [L]
+1
source
$route['en/search/(:any)'] = "en/search/$1";

Basically, this reassigns something using / en / search / something for the class, search method and search query will be passed as a parameter.

: , , , , , .

0
$searchtext = $this->url->segment(2);

should get the value "widget" in codeigniter. (Sorry if I had a question wrong).

0
source

All Articles