来自带有pattern-
的网址http://example.com/top-100-selenium-interview-questions-answers.html?format=pdf
我想重定向到
http:// example.com/istqb_dump.pdf
我创建了重定向遵循规则。
RewriteCond %{QUERY_STRING} format=pdf [NC]
RewriteRule .* http:// example.com/istqb_dump.pdf? [R=301,L]
工作正常。
现在还有其他网址,如下所示 -
http://example.com/top-35-seo-interview-questions/?format=pdf
http://examplecom/top-15-digital-marketing-interview-questions/?format=pdf
我想重定向到相应的网址
http:// example.com/seo.pdf
http:// example.com/digital-marketing.pdf
但是根据上述规则,所有网址都会重定向到
http:// example.com/istqb_dump.pdf
如何配置执行重定向?
答案 0 :(得分:1)
您需要使RewriteRule
更具体,为每个案例创建一个定制条件:
RewriteCond %{QUERY_STRING} format=pdf [NC]
RewriteRule ^top-100-selenium-interview-questions-answers.html /istqb_dump.pdf? [R=301,L]
RewriteCond %{QUERY_STRING} format=pdf [NC]
RewriteRule ^top-35-seo-interview-questions/? /seo.pdf? [R=301,L]
RewriteCond %{QUERY_STRING} format=pdf [NC]
RewriteRule ^top-15-digital-marketing-interview-questions/? /digital-marketing.pdf? [R=301,L]
在这里演示:http://htaccess.mwl.be?share=97bf4828-2ec0-551e-8bc1-4fb9f2f0f278