Apache 使用变量查询参数进行htaccess重定向
你能帮我把这个弄好吗 我正试图改变方向Apache 使用变量查询参数进行htaccess重定向,apache,.htaccess,Apache,.htaccess,你能帮我把这个弄好吗 我正试图改变方向 /search.php?id=5GHU&distance=50&sort=title 或 或 到 i、 e.无论是一个查询字符串参数还是多个查询字符串参数,它们都应该放在那里 这就是我试过的 RewriteBase / RewriteCond %{QUERY_STRING} (?:^|&)id=([^&]+) RewriteRule ^search\.php$ /search/%1? [L,R=permanent] 谢
/search.php?id=5GHU&distance=50&sort=title
或
或
到
i、 e.无论是一个查询字符串参数还是多个查询字符串参数,它们都应该放在那里
这就是我试过的
RewriteBase /
RewriteCond %{QUERY_STRING} (?:^|&)id=([^&]+)
RewriteRule ^search\.php$ /search/%1? [L,R=permanent]
谢谢对不起,我把你的问题弄糊涂了,我现在明白了。所以 按如下方式修改.htaccess:
RewriteEngine On
RewriteRule "^/search.php$" "/search/" [L,R=301,QSA]
简而言之,它将获取查询字符串(以?
开头的/search.php后面的内容)并将其附加到“/search/”。这是通过QSA标志来重写规则的。无论您有多少个参数,它都会附加所有参数
看
所以
由于
/search/?a=1&b=2
未指定要使用的页面,因此它将使用配置中DirectoryIndex定义的默认页面。我更喜欢显式指定页面,但它不使用。谢谢-让我检查一下。
/search/?query_string_values
RewriteBase /
RewriteCond %{QUERY_STRING} (?:^|&)id=([^&]+)
RewriteRule ^search\.php$ /search/%1? [L,R=permanent]
RewriteEngine On
RewriteRule "^/search.php$" "/search/" [L,R=301,QSA]
/search.php?a=1&b=2 --> /search/?a=1&b=2
/search.php?c=3 --> /search/?c=3