We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10357
    • 573 Posts
    Hi,

    I am trying to limit my modx site to one referring domain! I have this rule:

    RewriteCond %{HTTP_REFERER} .
    RewriteCond %{HTTP_REFERER} !domain\.co.uk [NC]
    RewriteRule .? - [F]`

    which sort of works apart from my css and images do not load, I guess it conflicts with the FURL rules. Any ideas how I can get them working together?
      • 1343 ☆ A M B ☆
      • 2,213 Posts
      Hello,

      The default ht.access code should do the trick:

      #RewriteCond %{HTTP_HOST} .
      #RewriteCond %{HTTP_HOST} !^example-domain-please-change\.com [NC]
      #RewriteRule (.*) http://example-domain-please-change.com/$1 [R=301,L]
      
        Patrick | Server Wrangler
        About Me: Website | Tweets |  MODX Hosting
        • 10357
        • 573 Posts
        sorry I was not clear - I was talking about all referring traffic

        Here is the solution:

        RewriteCond %{HTTP_REFERER} .
        RewriteCond %{HTTP_REFERER} !domain\.co.uk [NC]
        RewriteCond %{HTTP_REFERER} !appoveddomain\.co.uk [NC]
        RewriteRule .? - [F]`
          • 1343 ☆ A M B ☆
          • 2,213 Posts
          The above code should switch any traffic on a site to the domain name listed, instead of requiring you to list all of the domain name you wish to redirect to the main domain.

          If you parked say..
          domain1.com
          domain2.com
          domain3.com

          On the same site, but only wanted domain1.com to actually function (the others being redirected to it), then you would just do:

          RewriteCond %{HTTP_HOST} .
          RewriteCond %{HTTP_HOST} !^domain1\.com [NC]
          RewriteRule (.*) http://domain1.com/$1 [R=301,L]

          If you visited domain2.com it would redirect you to domain1.com (preserving the requested file/page).

          Regardless, I'm glad you got it doing what you wanted smiley
            Patrick | Server Wrangler
            About Me: Website | Tweets |  MODX Hosting