php - redirect adding %20HTTP to end of the url -
im redirecting this:
example.com/category/name-of-title/number
to this:
example.com/name-of-title/number
everything working perfect except adding %20http
end of url after redirect so:
example.com/name-of-title/number%20http
here code:
rewritecond %{the_request} /category/(.*)/(.*) [nc] rewriterule ^ /%1? [r=301,l]
because as documentation states, the_request
is
“[t]he full http request line sent browser server (e.g., "get /index.html http/1.1")”
– in case, get /category/name-of-title/number http/1.1
, , applying pattern /category/(.*)/(.*)
onto results in part name-of-title/number http
first match (and remaining 1.1
second), because of greediness of regular expressions.
it nonsense anyway use rewritecond
, value the_request
– simple rewriterule
should work fine:
rewriterule ^category/(.*)/(.*)$ /$1/$2 [r=301,l]
and if want match anything behind category/
anyway, don’t need 2 capturing subpatterns, use
rewriterule ^category/(.*)$ /$1 [r=301,l]
Comments
Post a Comment