初学者的apache mod_rewrite帮助.htaccess配置

时间:2010-02-05 19:07:48

标签: .htaccess mod-rewrite

当谈到 .htaccess 时,

noob。

我需要一个URL的mod_rewrite。 URL示例如下所示:

http://example.com/folder/script.php?location=UK&Name=Fred

我希望它转换为:

http://example.com/folder/UK/Fred

2 个答案:

答案 0 :(得分:1)

尝试此规则:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1/script.php?location=$2&Name=$3

这会将/<folder>/<location>/<Name>内部的请求重写为/<folder>/script.php?location=<location>&Name=<Name>

答案 1 :(得分:1)

RewriteCond %{QUERY_STRING} location=([^&]+)&Name=(.+)
RewriteRule ^/folder/script.php$ http://website.com/folder/%1/%2? [R]