I'd like to convert a URL like
http://mysite.com/search/search_mgmt.php?CategoryID=1
to something like
http://mysite.com/search/my-seo-friendly-url
I have mod_rewrite en开发者_StackOverflowabled.
What do you want to achieve? If somethings gets to your site with search/search_mgmt.php?CategoryID=1
and you want to convert it to search/my-seo-friendly-url
, you will have to redirect traffic to another URL:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^mysite.com/search/search_mgmt.php?CategoryID=1$ http://mysite.com/search/my-seo-friendly-url [R=301,L]
With this rule, the server will send the client code 301 Moved Permanently
with Location:
header set to the new URL. You can change 301 code to 302 (Found): [R=302,L]
. (Note: in this case the client sends two requests to your server to get the content.)
If you don't add this result specifier, then your server will just return the result as if it was accessed with re-written URL. So I guess you actually would like users to see your my-seo-friendly-url
whereas on the server it would be handled by search_mgmt.php?CategoryID=1
. You can do it this way:
RewriteRule ^mysite.com/search/my-seo-friendly-url$ http://mysite.com/search/search_mgmt.php?CategoryID=1
精彩评论