mod_rewrite question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nmcog
    Confirmed User
    • Sep 2004
    • 825

    #1

    mod_rewrite question

    What I'm trying to do:
    Display different different pages depending on the domain in HTTP Refer

    Example:
    1) Traffic from abc.com gets redirected to http://www.mydomain.com/index-abc.html

    2) Traffic from xyz.com gets redirected to http://www.mydomain.com/index-zyx.html

    3) Traffic from no referer (bookmark) gets redirected to
    http://www.mydomain.com/index-bookmark.html

    Also, the redirection should be invisible, i.e. the page contents will be of a different page but it will show as http://www.mydomain.com/
  • nmcog
    Confirmed User
    • Sep 2004
    • 825

    #2
    I've tried this code but it doesn't seem to work:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?abc.com.*$ [NC]
    RewriteRule (.*) http://www.mydomain.com/index-abc.html [R=permanent,L]

    Comment

    • Lycanthrope
      Confirmed User
      • Jan 2004
      • 4517

      #3
      RewriteEngine on
      RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?abc.com.*$ [NC]
      RewriteRule (.*) http://www.mydomain.com/index-abc.html [R=permanent,L]

      take out the exclamation point before ^http... Right now you are telling your server to redirect everyone that ISN'T from that domain to the page you meant for that domain. (!=NOT)

      Comment

      • s9ann0
        Confirmed User
        • Sep 2001
        • 4873

        #4
        try this for the no-referer:


        RewriteCond %{HTTP_REFERER} =""
        RewriteRule (.*) http://www.mydomain.com/index-bookmark.html [R=permanent,L]

        Comment

        • nmcog
          Confirmed User
          • Sep 2004
          • 825

          #5
          Thanks Lycanthrope & spanno!

          Comment

          • nmcog
            Confirmed User
            • Sep 2004
            • 825

            #6
            Is it possible to get it to show http://www.mydomain.com/ in the browser but really show the contents of index-abc.html?

            Comment

            • teksonline
              So Fucking Banned
              • Jan 2005
              • 2904

              #7
              wepws double post deleted
              Last edited by teksonline; 04-13-2005, 03:36 PM.

              Comment

              • teksonline
                So Fucking Banned
                • Jan 2005
                • 2904

                #8
                yes, not gonna sit down and figure it out for you as im busy but
                play with this line...

                RewriteRule ^index.html /index-abc.html [QSA,L]

                Comment

                Working...