简体   繁体   English

.htaccess具有3个参数的重写规则

[英].htaccess Rewrite Rule with 3 parameters

I am trying to achive a 301 redirect with the following rule: 我正在尝试使用以下规则实现301重定向:

RewriteEngine On
RewriteRule ^daily_de.0.html?year=(.*)&month=(.*)&day=(.*)$ /extra/?date=$1.$2.$3 [R=301,L,NE]

The old page (daily_de.0.html including parameters) should redirect to the new page (eg /extra/?date=10.09.2015) 旧页面(包括参数的daily_de.0.html)应重定向到新页面(例如/extra/?date=10.09.2015)

Not working so far :( Any help appreciated! 到目前为止还没有工作:(任何帮助表示赞赏!

You cannot match query string in a RewriteRule . 您不能在RewriteRule匹配查询字符串。 Use it like this with a RewriteCond : 这样与RewriteCond一起使用:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^year=(\d+)&month=(\d+)&day=(\d+)$ [NC]
RewriteRule ^daily_de\.0\.html$ /extra/?date=%1.%2.%3 [R=301,L,NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM