0
votes

Here is a sample URL with query string. The keyword is anything that User Search in my website or redirect from other websites, search engines etc.

http://example.com/search.php?q=keyword

and the equivalent CodeIgniter URL

http://example.com/search/now/keyword (search = controller and now = method)

How to Rewrite the URLs in Apache .htaccess to create URLs like CodeIgniter?

2
Are you sure this is what you want? - dan.dev.01

2 Answers

1
votes
RewriteRule ^/?search/now/(.*)$ /search\.php?q=$1

OR you can hide url query

RewriteRule ^search.php?id=(.*)$ /search.php [L,R=301]
0
votes

Firstly you don't want to be pointing to a php file. CI only has index.php, If you are desperate you could point all search.php to index.php...

I'd approach it on this basis...

POST the form to the controller, use form validation to make the input safe the take the variable and use the redirect function like this

redirect('/search/'.$this->input->post('q') );