Reputation: 1418
I need to redirect some URL with query string to a different URL
like
redirect 301 /web/works/?id=1 https://www.example.com/it/my_work_new_page/
.htaccess seem to ignore this
but if i add
redirect 301 /it/fake/ http://www.test.it
it works
I already have a file with about 100 of this redirect
Upvotes: 1
Views: 351
Reputation: 785128
You cannot match query string using Redirect
directive. Use mod_rewrite
with a RewriteCond
directive like this:
RewriteEngine On
RewriteCond %{THE_REQUEST} /web/works/\?id=1\s [NC]
RewriteRule ^ https://www.example.com/it/my_work_new_page/? [L,#=301]
?
in the target will strip previously existing query string.
Upvotes: 1