1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect Help

Discussion in 'General Scripting Chat' started by lord1027, Sep 25, 2014.

  1. lord1027

    lord1027 Elite Member

    Joined:
    Sep 20, 2013
    Messages:
    3,174
    Likes Received:
    2,222
    Hey guys, I have a small question for you. I think it can be done in .htaccess, but I just didn't manage to find a working solution yet.
    Basically, I want a domain and all it's subpages to redirect to a specific URL, pretty much like this:

    Whenever someone tries to visit mydomain.com/anypage/1234 he would get redirected to http://www.somethingstatic.com/anypage/1234 (in URL encoded form).

    Example:
    Visitor lands on www.mydomain.com/something/else/123, he would get redirected to http://www.somethingstatic.com//something/else/123

    Basically, I want mydomain.com/* to point to seconddomain.com/* (with * URL encoded this time)

    Does anyone know how to do this?
     
  2. africanart

    africanart Regular Member

    Joined:
    Jan 25, 2014
    Messages:
    249
    Likes Received:
    71
    Occupation:
    Re-watching Star Wars
    Location:
    Atlantis
    You will need to get a redirect plugin and redirect individual pages. Doing it on .htaccess would probably slow down the loading time. Just like blocking up a huge list of ips using .htaccess
     
  3. lord1027

    lord1027 Elite Member

    Joined:
    Sep 20, 2013
    Messages:
    3,174
    Likes Received:
    2,222
    You don't understand, I don't want it for specific pages, I want it for any URL following my domain. These pages do not actually exist, but if someone tries to visit mydomain.com/1234 he needs to get redirected to seconddomain.com/1234 (plus the URL encoded part)
     
  4. Dj Co2

    Dj Co2 Elite Member

    Joined:
    Aug 21, 2009
    Messages:
    1,519
    Likes Received:
    2,355
    I don't think this can be implemented with .htaccess. You will have to go through every page's html and add the redirection code. OR if you're using wordpress then you can do it with plugin Pretty Link
     
    • Thanks Thanks x 1
  5. lord1027

    lord1027 Elite Member

    Joined:
    Sep 20, 2013
    Messages:
    3,174
    Likes Received:
    2,222
    I don't need an actual website or something, so no wordpress. I just want every visitor that comes to my domain (direct link) to "www.mydomain.com/test-link-for-example" to get redirected to "www.seconddomain.com/test-link-for-example".
     
  6. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,155
    Here you go:

    Code:
    RewriteEngine on 
    RewriteRule ^(.*)$ http://www.mattcutts.com/$1 [R=301,L]
    
     
    • Thanks Thanks x 1
  7. lord1027

    lord1027 Elite Member

    Joined:
    Sep 20, 2013
    Messages:
    3,174
    Likes Received:
    2,222
    The code works pretty well, with one exception. I'm trying to use this for affiliate purposes, so let me show you how the redirect url should look like:
    Code:
    http://event.affiliatetracker.com/events/click?ad_type=quicklink&aff_code=xxxxx&unique=xxxxx&redirect_to=http%253A%252F%252Fwww.test.com%252Furl-to-product 
    The URL after redirect_to is double encoded.
    Right now, the current htaccess redirects me to
    Code:
    http://event.affiliatetracker.com/events/click?ad_type=quicklink&aff_code=xxxxx&unique=xxxxx&redirect_to=http53A52F52Fwww.test.com52Furl-to-product 
    Which is single encoded. Could anyone help me modify the htaccess so that it redirects to double encoded?
     
  8. xobbit

    xobbit Newbie

    Joined:
    Apr 23, 2013
    Messages:
    10
    Likes Received:
    1
    YouTube Channel names are shortened by a Python script which spoofs "custom' URLs from almost unbreakable code. Only redirect-checker on "try" subdomain of "seoimage" site (sorry no links allowed for me yet) can detect such things, but it still can, so you might use it for checking.

    However, I don't know how to use it to check a list of URLs, e.g. from a file, as it's form data exchange is hidden - can anyone please advise a way to mass-check redirects?