如何使用Htacess的www.example.com/type.php?user=name如何使用、www、example、com

2023-09-02 11:40:40 作者:神都偏爱我

我要重定向 www.example.com/type/name www.example.com/type.php?user=name

{
    RewriteRule ^([a-zA-Z0-9_-]+)/type$ type.php?key=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/type/$ type.php?key=$1
}

请帮我这件事。

推荐答案

试试这个,希望它可以帮助:

RewriteBase /www.example.com
RewriteEngine On


RewriteRule ^type/(.*)/$ /type.php?user=$1
#OR
RewriteRule ^(.*)/(.*)/$ /$1.php?user=$2

PS:第一种方法仅适用于网址: www.example.com/type/value 的,第二个适用于您的站点前的任何页面: www.example.com/anypage/value 的

PS : The first one works only for the url : www.example.com/type/value ,the second one works for any page in your site ex: www.example.com/anypage/value