• Hello. There are some bad links I’ve seen. Examples

    ?_escaped_fragment_=about
    ?ref
    ?replytocom
    #!…

    How do I redirect them to a post with htaccess? Can we do this with one code? thanks

    Examples:

    1- site.com/page1.html/?_escaped_fragment_=

    to site.com/page1.html/

    2- site.com/page1.html/?ref

    to site.com/page1.html/

    3- site.com/page1.html/?replytocom

    to site.com/page1.html/

    4- site.com/page1.html/#!

    to site.com/page1.html/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Query strings and skip links aren’t really part of the requested path/file, they are added parameters. Unless the target page is using them, they do not accomplish anything. Why do you need to remove those portions if they do not accomplish anything?

    In any case, you cannot really get rid of them without changing the requesting source. You can redirect elsewhere if certain values were passed. You can change the passed values if they were formatted correctly to begin with (your examples are not). But you cannot make them just go away. Additionally, you would need to match some sort of pattern to be able to take an action. Any rule that blindly dealt with all query strings would break legitimate functionality.

    Thread Starter devrekli

    (@devrekli)

    @bcworkz

    Because these bad links google indexing. So I want to redirect with htaccess.

    If you’re just concerned about search engines indexing them, you could always just set the strings to Disallow in the site’s robots.txt file.

    Disallow: /?_escaped_fragment_=
    Disallow: /?ref
    Disallow: /?replytocom
    Disallow: /#!

    Though like some one else mentioned, it would be better to find out what’s causing those strings and if they are really valid.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirecting bad links with htaccess?’ is closed to new replies.