Search code examples
.htaccessurl-rewritingwhitespace

301 htaccess with %20 in target URL


I need to manage some URL in query string. The landing URL contains space (%20). I wrote this:

RewriteCond %{QUERY_STRING} ^orderby=([0-9]+)&pagenumber=([0-9]+)$
RewriteRule ^[OLD-SLUG]$ https://www.domain-site.it/Content/Images/uploaded/[TEXT-01]%20[TEXT-02]%20[TEXT-03].pdf? [R=301,L]

But the result is that the URL redirects to:

https://www.domain-site.it/Content/Images/uploaded/[TEXT-01]50[TEXT-02]50[TEXT-03].pdf

What's wrong?

Thanks all


Solution

  • I've solved it in this way:

    RewriteCond %{THE_REQUEST} ^(\S*)\s/(\S*) [NC]
    RewriteCond %{QUERY_STRING} ^orderby=([0-9]+)&pagenumber=([0-9]+)$
    RewriteRule ^old-slug$ https://www.domain-site.it/Content/Images/uploaded/[TEXT-01]\%20[TEXT-02]\%20[TEXT-03].pdf? [R=301,L,NE]
    

    Tks all!