Apache rewrite query string to CodeIgniter like URL
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.
htt开发者_StackOverflow社区p://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?
RewriteRule ^/?search/now/(.*)$ /search\.php?q=$1
OR you can hide url query
RewriteRule ^search.php?id=(.*)$ /search.php [L,R=301]
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') );
精彩评论