1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

htaccess redirect

Discussion in 'Programming' started by riverrun, Jun 23, 2008.

  1. #1
    I have sifted through all the top results in google for a way to redirect a user based on the referer data. I want to refer visitors from 1 site and 1 of its subdomains to an article when they visit the site. From everything I have read I came up with the following:

    RewriteEngine On
    RewriteCond %{HTTP_referer} ^http://(www\.)?example\.com/ [NC]
    RewriteCond %{HTTP_referer} ^http://subdomain\.example\.com/ [NC]
    RewriteRule .* http://www.mysite.com/article/ [R,L]
    Code (markup):
    I have not been able to test the subdomain rewrite condition but the domain one does the redirect but gives the following error:

    The page isn't redirecting properly
    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
    This problem can sometimes be caused by disabling or refusing to accept cookies.

    From what I've read it is probably looping? I have SEF urls enabled through joomla, not sure it matters or not. I real have no knowledge of this but have always found solutions with google. Any help would be great.
    SEMrush
    Thanks
     
    riverrun, Jun 23, 2008 IP
    SEMrush
  2. King Goilio

    King Goilio Member

    Messages:
    200
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    33
    #2
    RewriteEngine On
    RewriteCond %{HTTP_referer} ^http://(www\.)?example\.com/ [NC]
    RewriteCond %{HTTP_referer} ^http://subdomain\.example\.com/ [NC]
    RewriteRule .* http://www.mysite.com/article/ [R=301,L]
    Code (markup):
    adding the =301 tells the browser that the page has been moved so follow the redirect
     
    King Goilio, Jun 23, 2008 IP
    riverrun likes this.
  3. riverrun

    riverrun Active Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    thanks for the reply but it seems to still be causing an infinite loop and redirecting to itself? Is there a way to clear the referer info so this doesn't happen or exclude it from that specific article?
     
    riverrun, Jun 23, 2008 IP
  4. riverrun

    riverrun Active Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Options +FollowSymLinks
    RewriteCond %{HTTP_referer} ^http://(www\.)?example\.com/ [NC[B],OR[/B]]
    RewriteCond %{HTTP_referer} ^http://subdomain\.example\.com/  [NC]
    RewriteRule [B]^$[/B] http://www.mydomain.com/article/ [R=301,L]
    Code (markup):
    The above now works for the example.com...I can't test from the subdomain but I will assume it also now works...anyone know how to test by manually adding the referrer info in your browser?
     
    riverrun, Jun 23, 2008 IP
  5. Bryce

    Bryce Peon

    Messages:
    1,235
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Are you sure you want to do a 301 redirect? This essentially means "Moved Permanently", so if for example, a search engine followed the link from the referrer site, it would assume your normal page has been "Moved Permanently".

    btw, looks like you've got everything else working properly, including the ,OR to evaluate the second condition. I'm just worried you might be redirecting search engines (unless that's what you want) ??
     
    Bryce, Jun 23, 2008 IP
  6. riverrun

    riverrun Active Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    The website that is referring is all no follow and it is an ad on that site that users click through. I never thought about the SE issue that could arise but I think since its no follow and an ad I shouldn't have any issues with mainly google.

    Am I right with this thinking?
     
    riverrun, Jun 24, 2008 IP
  7. Bryce

    Bryce Peon

    Messages:
    1,235
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The nofollow attribute applies to the passing of Pagerank. Google definitely follows all links for general indexing purposes. I can tell you that for certain because the simplest trick to get indexed in Googe is to post a comment on DoshDosh, TechCrunch or Shoemoney but all those blogs have nofollow comments.
     
    Bryce, Jun 24, 2008 IP
    riverrun likes this.
  8. riverrun

    riverrun Active Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #8
    So could google follow one on those links and take my site out of the index even though other sites that they index point to my site and the site exists through those?

    Should I take the 301 away and change it to something else?
     
    riverrun, Jun 24, 2008 IP
  9. Bryce

    Bryce Peon

    Messages:
    1,235
    Likes Received:
    93
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I'm not sure if it would take you out of the index but it could cause issues with duplicate content. If it were my site, I think I'd avoid using the 301. One of the best articles I've found on the subject is here.

    btw, if you need to test your redirects, I have a few domains with subdomains and could easily put up a couple of test pages, PM me if necessary.
     
    Bryce, Jun 24, 2008 IP