我试图找出如何做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重定向与查询字符串与不同的查询字符串的新域名
发布评论