Ask Your Question
2

How can a domain be redirected for all of its URLs while also allowing hotlinking exclusively for approved websites?

asked 2021-05-15 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-04-16 14:00:00 +0000

ladyg gravatar image

To redirect a domain for all of its URLs, you can use a 301 redirect. This will ensure that all traffic to the old domain is redirected to the new domain. Here's how to do it:

  1. Log in to your domain registrar and navigate to the DNS settings for your domain.
  2. Create a new CNAME record for your domain that points to the new domain.
  3. Update the A record for your domain to point to the IP address of the server that hosts your website.
  4. Add a .htaccess file to your server and add the following code:

on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?approvedsite\.com [NC] RewriteRule \.(gif|jpe?g|png)$ - [NC,F,L]

This code will allow hotlinking only for the approved website, and all other requests will be denied with a 403 Forbidden error.

  1. Test the redirection and hotlinking. Type in the old domain name to see if it redirects to the new domain, and try to hotlink an image from an unapproved site to make sure it's blocked.

With these steps, you can redirect your domain for all of its URLs while also allowing hotlinking exclusively for approved websites.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-15 11:00:00 +0000

Seen: 11 times

Last updated: Apr 16 '21