使用mod_rewrite,我怎么可以把网址遵循这个模式是:
Using mod_rewrite, how could I turn URLs that follow this pattern:
http://example.com/index.php?id=14
进入该模式:
http://example.com/14/
当我想到你,而要改写请求 /< ID> /
内部以 /index.php?id=<ID>
,试试这个:
As I think that you rather want to rewrite requests to /<ID>/
internally to /index.php?id=<ID>
, try this:
RewriteRule ^(d+)/$ index.php?id=$1
但如果你真的想要请求重定向到 /index.php?id=<ID>
内部以 /&LT; ID&GT; /
:
RewriteCond %{QUERY_STRING} (^|&)id=(d+)(&|$)
RewriteRule ^index.php$ /%2/? [R]
如果你想preserve其他可能的URL参数:
And if you want to preserve possible other URL arguments:
RewriteCond %{QUERY_STRING} ^(([^&]*&+)*)id=(d+)(&+(.*))?$
RewriteRule ^index.php$ /%3/?%2%5 [R]