从网址301重定向与查询字符串与不同的查询字符串的新域名

编程入门 行业动态 更新时间:2024-10-23 23:29:22
本文介绍了从网址301重定向与查询字符串与不同的查询字符串的新域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图找出如何做301重定向在我的htaccess文件的一些文件重定向到一个新的领域。这就是我需要知道怎么做:

旧的URL: www.example/index ?PHP页面=新闻和ID = 2366

新的URL: www.example2/news.php?name = 23546

的重定向不必自动创建。我可以硬code,我需要在htaccess文件重定向页面,我只是不知道要使用的格式,因为我读过,标准的301重定向不会与查询字符串的工作。

基本上这就是我想做的事情,但是从我的研究到目前为止,它听起来并不像它可以做到这样。

重定向301 /index.php?page=news&id=2366 www.example2/news.php?name=23546

解决方案

您可以使用一个重写规则与查询字符串匹配条件,如:

RewriteEngine叙述上 的RewriteCond%{REQUEST_URI} ^ / index.php的$ 的RewriteCond%{QUERY_STRING} ^页=新闻和ID = 2366 $ 重写规则^(。*)$ www.example2/news.php?name=23546 [R = 301,L]

结帐这个博客页面关于它如何工作的更多信息。

I am trying to figure out how to do a 301 redirect in my htaccess file to redirect some files to a new domain. Here's what I need to know how to do:

OLD URL: www.example/index.php?page=news&id=2366

NEW URL: www.example2/news.php?name=23546

The redirects don't have to be automatically created. I can hard-code the pages I need to redirect in the htaccess file, I just don't know the format to use as I've read that a "standard" 301 redirect won't work with query strings.

Basically this is what I want to do, but from my research so far it doesn't sound like it can be done this way.

redirect 301 /index.php?page=news&id=2366 www.example2/news.php?name=23546

解决方案

You could use a rewrite rule with a query string match condition, such as:

RewriteEngine On RewriteCond %{REQUEST_URI} ^/index.php$ RewriteCond %{QUERY_STRING} ^page=news&id=2366$ RewriteRule ^(.*)$ www.example2/news.php?name=23546 [R=301,L]

Checkout this blog page for more information on how this works.

更多推荐

从网址301重定向与查询字符串与不同的查询字符串的新域名

本文发布于:2023-11-01 17:50:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   重定向   新域名   网址

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!