301 redirect htaccess /% E2% 80% 8E

2

I am not able to redirect a www.miweb.com/%E2%80%8E to www.miweb.com

I tried htaccess:

Redirect 301 /%E2%80%8E http://www.miweb.com

Php

$cadena = 'http://www.miweb.com/%E2%80%8E';
if(preg_match('/\/%E2%80%8E/', $cadena)){
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: http://www.google.es" );
}
    
asked by Infobuscador 01.07.2016 в 11:54
source

3 answers

3
RewriteCond %{THE_REQUEST} "%E2%80%8E" 
RewriteRule . http://www.example.com [L,R=301]

You have to use %{THE_REQUEST} to matchear the request before it is decoded, that's why

RewriteRule "%E2%80%8E" http://www.example.com [L,R=301]

It does not work, but this does:

RewriteRule "‎" http://www.example.com [L,R=301]

Also it seems that you are redirecting within the same server, then you do not need to put http://loquesea/blahblah , you can do it like this:

RewriteCond %{THE_REQUEST} "%E2%80%8E" 
RewriteRule . / [L,R=301]
    
answered by 01.07.2016 / 15:16
source
0

Simply overwrite the rule:

RewriteRule /\xE2\x80\x8E$ http://www.miweb.com [L,R=302]
    
answered by 01.07.2016 в 11:57
0

Try this:

$cadena = 'http://www.miweb.com/%E2%80%8E';
if(preg_match('/%E2%80%8E/', $cadena))
{
    $urlRedireccion = "http://www.google.es";
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: $urlRedireccion");
}

EDITION:

?>
<script type="text/javascript">
    document.location.replace("http://www.google.es");
</script>
<?php
    
answered by 01.07.2016 в 12:08