Using .htaccess, how do I convert this URL
http开发者_StackOverflow://engine.searchr.us/web-search.phtml?search=SEARCHED+TEXT
to
http://engine.searchr.us/web-search/search/SEARCHED-TEXT.html
?
and I should place the .htaccess in the engine folder right?
Here's a start:
Making the Query String Part of the Path
Take a URL of the form http://example.com/path?var=val and transform it into http://example.com/path/var/val. Note that this particular example will work only for a single var=val pair containing only letters, numbers, and the underscore character.
RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule ^/path /path/%1/%2?
You'll have to do something about the spaces/pluses in the search term. I would really recommend implementing some kind of CGI script as Martin suggested, but I think you could keep rewriting the QUERY_STRING portion until all spaces are dashes as well (you're going to have to figure that out on your own though!)
Good luck!
http://wiki.apache.org/httpd/RewriteQueryString http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
I don't think this is possible, with just the standard Apache modules. mod_rewrite
might be closest, but it can't process the QUERY_STRING. So you'll have to implement some kind of server-side code (CGI, PHP, mod_python) to implement the redirect. I'd personally use a Python-implemented CGI script.
精彩评论