It seems we have some weird broken incoming links for our website that we would like to redirect. We are using Laravel on Apache.
Here is the incoming url: /flannel-sheets%C2%A0
Here is where we want to send it: /flannel-sheets
%C2%A0 seems to decode to a strange space.
I have tried these lines in the web.php
file
$this->get( 'flannel-sheets%C2%A0', function() { return redirect( '/flannel-sheets' ); });
$this->get('flannel-sheets ', function() { return redirect( '/flannel-sheets' ); });
$this->get('flannel-sheets$nbsp;', function() { return redirect( '/flannel-sheets' ); });
I have also tried using Apache redirects in my 000-default.config
and .htaccess
files
Redirect 301 /flannel-sheets%C2%A0 https://example.com/flannel-sheets
Neither of these methods are working for me. What should I do?
2
Answers
So it is a non-breaking space (0xC2 0xA0).
Annoying to deal with these once they are in the wild, bad inbound links that is.Using
mod_rewrite
is probably the best option here. Something like this would work…You’ll want to check for those characters, not their URL encodings. I’m wondering if
mod_speling
offers anything useful for this scenario… not seeing anything so far.you can fix it using :
or you can receive the broken routes dynamically