通过HTACCESS重定向具有多个参数的URL [英] Redirecting URLs with Multiple Parameters via HTACCESS

查看:70
本文介绍了通过HTACCESS重定向具有多个参数的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何在htaccess文件中重定向301?

How would I do this 301 redirect in my htaccess file?

旧网址

http://www.domain.com/newsletter/modules.php?op=modload&name=News&file=article&sid=221

http://www.domain.com/newsletter/modules.php?op=modload&name=News&file=article&sid=224

新网址

对于221- https://www.domain.com/news/

对于224- https://www.domain.com/treatments /laser-comb/iso-certification/

说明:除了结尾的文章ID号外,基本上所有旧url中的内容都相同.

Explanation: Basically everything is the same in the OLD urls except for the article ID number at the end.

推荐答案

在htaccess文件顶部,添加以下内容:

At the top of your htaccess file, add the following :

RewriteEngine on

#1)
RewriteCond %{THE_REQUEST} /newsletter/modules\.php\?op=modload&name=News&file=article&sid=221 [NC]
RewriteRule ^ http://www.domain.com/news/? [L,R=301]
#2)
RewriteCond %{THE_REQUEST} /newsletter/modules\.php\?op=modload&name=News&file=article&sid=224 [NC]
RewriteRule ^ https://www.domain.com/treatments/laser-comb/iso-certification/? [L,R=301]

这篇关于通过HTACCESS重定向具有多个参数的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆