开发者

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') );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜