【问题标题】:htaccess redirection when URL has ? query stringURL有时的htaccess重定向?请求参数
【发布时间】:2017-08-28 09:04:32
【问题描述】:

来自带有模式的 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

我想重定向到相应的 URL 直播

http://example.com/seo.pdf

http://example.com/digital-marketing.pdf

但是按照上面的规则,所有的 URL 都会重定向到

http://example.com/istqb_dump.pdf

如何配置独立重定向?

【问题讨论】:

标签: .htaccess redirect mod-rewrite url-redirection


【解决方案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

【讨论】:

    猜你喜欢
    • 2022-07-01
    • 1970-01-01
    • 2022-12-29
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多