SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,761
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    301 Redirect an Hex Characters or "\" Out of Incoming Url

    While I don't understand it,

    Tons of incoming links to our sites have either an accidental extra space or some strange character at the end of the url in their href, which creates 404 returns when they arrive to my site.

    Is it possible to have a rewrite condition that if it spots three things, either "\", or any url encoding to 301 redirect that out. They are always at the end.

    I'm seeing "\", %5C, %3C, %20, and a few others.

    Trying to enjoy the link gain rather then feeding 404.

    I use NGINX.

    Cheers!
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    cb,

    mod_rewrite understands encoded characters so you can include them inside character range definitions as their "real" (printable) character. Note, though, that %20's space is used in the syntax of a mod_rewrite statement so it MUST be escaped (with a \). The \ character should never be used in a URI and it should be escaped if you're trying to match it within a query string.

    NGINX? Dunno, but if they're trying to emulate the Apache.org people, it'll be the same.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,761
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay,

    So my main goal it would be seem is to do a rewrite where, if the URL does contain a '%' sign, suggesting bad formed URL, I just stop the url and 301 redirect to the entire URL before the % sign (and leave off whatever comes after).

    Working on a way to do that, but haven't found a solution just yet. And you are right, NGINX is very close to mod_rewrite.

    Cheers
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    cb,

    I suspect that you can't "catch" a % in a URL because it's a reserved character in a URI which denotes character encoding. In that case, I'd suggest (1) checking your visitor log for "hack attacks" utilizing character encoding like that and (2) specify the characters you will accept at your website (i.e., [a-z.]+ for all lowercase characters and the dot character ... aw, add the / character, too, and Fail everyone else! You can only do so much babysitting visitors and a redirection (rather than my harsh Fail) should take visitors to a sitemap which can be used to single-click to every page in your website.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •