2016-11-04 115 views
1

我该如何做到这一点301在我的htaccess文件中重定向?通过HTACCESS重定向具有多个参数的URL

旧网址

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号码之外,基本上所有的东西都是一样的。

+0

我不是一个开发商。对于类似的重定向问题,找到许多有用答复的外行人。目前没有任何尝试。 – StackBurger

回答

1

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

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] 
+0

什么是'THE_REQUEST'? –

+0

这是一个预定义的服务器变量。 请阅读mod-rewrite文档:http://httpd.apache.org/docs/current/mod/mod_rewrite.html – starkeen

+0

好的 - 我明白了。谢谢 –