2017-08-28 55 views
2

從URL與圖案 -htaccess何時URL重定向?查詢字符串

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] 

它工作正常。

現在還有其他的URL,以及像下面 -

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

更具體和你讓你的重寫規則匹配...? – CBroe

+0

我想重定向從url - http://example.com/top-100-selenium-interview-questions-answers.html?format=pdf 到此網址 http://example.com/istqb_dump.pdf 請告訴我.htaccess規則。 –

回答

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

相關問題