301重定向 - htaccess重定向.asp文件

时间:2013-11-07 20:46:28

标签: asp.net regex apache .htaccess mod-rewrite

问题:

我如何在.htaccess中重定向以下行:

Redirect 301   /reizen.asp?type=ind     http://domain.com/individuele-reizen
Redirect 301   /reis.asp?reisID=169     http://domain.com/individuele-reizen/oostenrijk/tirol-karinthie

我一直得到:错误:

The requested URL /reis.asp was not found on this server.

搜索堆栈溢出没有帮助。

1 个答案:

答案 0 :(得分:2)

您无法使用Rediect指令匹配QUERY_STRING。请改用mod_rewrite

RewriteEngine On

RewriteCond %{QUERY_STRING} ^type=ind$ [NC]
RewriteRule ^/?reizen\.asp$ /individuele-reizen? [L,NC,R=301]

RewriteCond %{QUERY_STRING} ^reisID=169$ [NC]
RewriteRule ^/?reis\.asp$ /individuele-reizen/oostenrijk/tirol-karinthie? [L,NC,R=301]