I have an external backlink which is linking incorrectly to my website.
They are adding /%E2%80%8E to the end of the link so it is coming in as http://mywebsite.com/%E2%80%8E .
I want to use htaccess to redirect these people to my homepage.
This is what I currently have:
#This version does not work for some reason
RewriteRule %E2%80%8E https://mysite.com [B,R,L]
RewriteCond %{QUERY_STRING} %E2%80%8E
RewriteRule .? https://mysite.com [B,R,L]
# This version works if I type in the DECODED version of the string
RewriteRule ‎ https://mysite.com [R,L]
RewriteCond %{QUERY_STRING} ‎
RewriteRule .? https://mysite.com [R,L]
Thanks
If you don't want to use the decoded string, you can use \\x##
. The reason why the decoded string works is that in RewriteRule
's, the URI is decoded before the pattern is applied.
RewriteRule ^\xE2\x80\x8E$ / [L,R=301]
Give this a try in your htaccess.
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/%E2%80%8E\s [NC]
RewriteRule ^ https://mysite.com/ [L,R=301]
You could solve this problem without using .htaccess rewrite. On some of my website I do check, either in the header of the page (with PHP or JS) or in a custom 404 page.
In my opinion this method is slightly better than mod rewrite just because it doesn't require you to have the mod_rewrite module enabled on the server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.