问题
Is it possible to set a forms action property automatically with mod_rewrite after clicking on a search button?
normal url is this: http://www.website.com/search.php?search=name
mod_rewrite url is this: http://www.website.com/search/name.html
I know that it is possible to set a mod_rewrite version of the page with htaccess, but how would I have the form go directly to the mod_rewrite url?
Regards
回答1:
This should work:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /search\.php\?search=(.*)\ HTTP
RewriteRule ^ /search/%2.html? [R=301,L]
RewriteRule ^search/(.*).html$ /search.php?name=$1 [L]
It should automatically turn the normal link into the mod_rewrite link.
来源:https://stackoverflow.com/questions/23681669/search-url-automatically-in-mod-rewrite-version