我需要找到正确查询的方法重定向301?

发布于 2025-02-03 13:26:33 字数 492 浏览 0 评论 0原文

我有一个有关重定向查询301 ...旧链接的问题

https://example.com/about.php?lang=1
新链接:https://example.com/about

我尝试了很多.htaccess规则的示例,但是如果有人可以帮助分享工作查询,则找不到重定向查询的规则?

我尝试的样本:

RewriteCond %{HTTP_HOST} ^example\.com$ RewriteCond %{QUERY_STRING} ^lang\=1$ 
RewriteRule ^/?about\.php$ example.com/about? [L,R=301,QSD,NC] 

RewriteCond %{QUERY_STRING} (^|&)lang\=1($|&) 
RewriteRule ^about\.php$ nalyvky.com/about [R=301,L]

I have a question about redirect query 301...

Old Link: https://example.com/about.php?lang=1
New Link: https://example.com/about

I try a lot of samples for rules for .htaccess, but can't find rules for redirect queries, if someone can help share the work query?

Sample that i'm try it:

RewriteCond %{HTTP_HOST} ^example\.com$ RewriteCond %{QUERY_STRING} ^lang\=1$ 
RewriteRule ^/?about\.php$ example.com/about? [L,R=301,QSD,NC] 

RewriteCond %{QUERY_STRING} (^|&)lang\=1($|&) 
RewriteRule ^about\.php$ nalyvky.com/about [R=301,L]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对风讲故事 2025-02-10 13:26:33

这可能是您要寻找的:

RewriteEngone on

RewriteCond %{QUERY_STRING} (^|&)lang=1(&|$)
RewriteRule ^/?about\.php$ /about [QSD,R=301,L]

它将所有请求重定向到https://example.com/about.php?lang=1 https://example.com/about通过301 HTTP响应。

通常,此类重定向与内部重写结合在一起,以便能够处理此类重定向请求:

RewriteEngone on

RewriteCond %{QUERY_STRING} (^|&)lang=1(&|$)
RewriteRule ^/?about\.php$ /about [QSD,R=301,L]

RewriteRule ^/?about/?$ /about.php?lang=1 [L]

假设HTTP主机与设置无关,您的问题对此有点模糊...

This probably is what you are looking for:

RewriteEngone on

RewriteCond %{QUERY_STRING} (^|&)lang=1(&|$)
RewriteRule ^/?about\.php$ /about [QSD,R=301,L]

It externally redirects all requests to https://example.com/about.php?lang=1 to https://example.com/about by means of a 301 http response.

Often such redirection is combined with an internal rewrite to be able to process such redirected requests:

RewriteEngone on

RewriteCond %{QUERY_STRING} (^|&)lang=1(&|$)
RewriteRule ^/?about\.php$ /about [QSD,R=301,L]

RewriteRule ^/?about/?$ /about.php?lang=1 [L]

This assumes that the http host is irrelevant for the setup, your question is a bit fuzzy in that ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文