Referer string at end of URL after redirect

Discussion in 'IT & Internet' started by UKSBD, Sep 5, 2019.

  1. UKSBD

    UKSBD Not a real duck Staff Member

    9,227 1,729
    I had categories for Dog Groomers and Dog Grooming in my directory, merged them together and redirected Dog Grooming to Dog Groomers

    The problem I have is when I go to Dog Grooming it redirects to Dog Groomers but the referrer string shows on the end of the URL

    Go to https ://www. uksmallbusinessdirectory.co.uk/category/dog+grooming/ to see what I mean.

    How do I get rid of the referrer string from the end of the URL?
     
    Posted: Sep 5, 2019 By: UKSBD Member since: Dec 30, 2005
    #1
  2. Mike Hayes

    Mike Hayes UKBF Enthusiast Free Member

    1,033 261
    How are you redirecting Dog Grooming to Dog Groomers? If done via .htaccess, you can update your existing rewrite / redirect rule to remove the query string; if not you can set up a rewrite rule using .htaccess to solve this.

    Try this rule:

    Code:
    RewriteRule ^category/dog\+grooming$ /category/dog+groomers? [L,R=301]
    The ? appended to the target URL ensures the internal query string isn't taken across.
     
    Posted: Sep 8, 2019 By: Mike Hayes Member since: Jan 7, 2016
    #2
  3. UKSBD

    UKSBD Not a real duck Staff Member

    9,227 1,729
    Cheers Mike

    I think that has worked

    Seems OK in FF after I delete all my cookies and site data
    Still doing it in Chrome and Opera but I assume it's because it's in my cache and I don't want to clear those.

    Is there a way of clearing .htaccess rules without having to delete all your browser cache ?
     
    Posted: Sep 8, 2019 By: UKSBD Member since: Dec 30, 2005
    #3
  4. UKSBD

    UKSBD Not a real duck Staff Member

    9,227 1,729
    Sorted it with a random string /category/dog+grooming/?1234

    edit: Sooke to soon it still goes to /category/dog+groomers/?strBusinessCatergory=dog+grooming on browsers which haven't cleared cache :-(

    Not really a problem as I can see it is working when going incognito
     
    Posted: Sep 8, 2019 By: UKSBD Member since: Dec 30, 2005
    #4
  5. Mike Hayes

    Mike Hayes UKBF Enthusiast Free Member

    1,033 261
    Great!

    An easy option in this scenario would be to use a new incognito / private browsing window. This uses a separate cache from your main browsing tabs, which of course is then also automatically cleared when the private window is closed. Great for testing.

    Other options are using curl (command line) or opening developer tools with caching disabled but in most cases the above is a good user friendly way to test without clearing your cache.
     
    Posted: Sep 8, 2019 By: Mike Hayes Member since: Jan 7, 2016
    #5
  6. UKSBD

    UKSBD Not a real duck Staff Member

    9,227 1,729
    thanks again, I think I must have been editing my post as you wrote yours though :)
     
    Posted: Sep 8, 2019 By: UKSBD Member since: Dec 30, 2005
    #6
  7. UKSBD

    UKSBD Not a real duck Staff Member

    9,227 1,729
    One more thing

    I couldn't adjust the existing rewrite / redirect rule as it's the same file for all categories, so used
    RewriteRule ^category/dog\+grooming$ /category/dog+groomers? [L,R=301] instead.

    Does that have to be above the existing rewrite / redirect rule to work or doesn't it matter where it goes?
     
    Posted: Sep 8, 2019 By: UKSBD Member since: Dec 30, 2005
    #7
  8. Mike Hayes

    Mike Hayes UKBF Enthusiast Free Member

    1,033 261
    I'm not entirely sure on the order to be honest. First would seem to make most sense to me so these redirections happen before routing into the application etc.

    It will unfortunately still have the query string appended on browsers which have cached a previous redirection response.

    You could do something like the following to fix that if it's important:

    This just checks for someone visiting the new page with the query string in place and then redirects them to the same page without the query string.

    Disclaimer - I haven't tested it!
     
    Posted: Sep 8, 2019 By: Mike Hayes Member since: Jan 7, 2016
    #8