.htaccess - 使用获取参数的 Htaccess 310 重定向

标签 .htaccess redirect seo

我在使用 get 参数进行 301 重定向时遇到问题。

我的旧网站有这样的 URL: http://www.mywebsite.com/contacts/?lang=fr

我今天上传了我的新网站。对于 seo,我想将此地址重定向到新地址:http://www.mywebsite.com/contact

我在我的 htaccess 中使用了这个重定向,但它不起作用....

RewriteCond %{QUERY_STRING} ^lang=fr$
RewriteRule ^contacts$ http://www.mywebsite.com/contact [L,R=301]

怎么了? 非常感谢:-)

最佳答案

使用以下规则,

RewriteCond %{QUERY_STRING} ^lang=fr$ [OR]
RewriteCond %{REQUEST_URI} ^contacts$
RewriteRule ^ http://www.mywebsite.com/contact [L,R=301]

关于.htaccess - 使用获取参数的 Htaccess 310 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42812179/

相关文章:

php - htaccess 用类别名称和帖子 url 重写文件夹

.htaccess - 更改托管域的文档根目录?

php - GZIP 压缩不适用于 Wordpress 网站

Angularjs SEO : is making html snapshots required anymore?

php - 基于 HTTP :X-FORWARDED-FOR 允许在 htaccess 中访问

php - .htaccess 重定向主域和附加域问题

apache - 在 .htaccess 中使用 keep-alive 功能

node.js - 带有 Passportjs 的客户端 session 模块

php - 通过 PHP CURL POST 数据并重定向用户

web - 阻止 Google(和其他搜索引擎)抓取域