krlaboratories

how to use IP canonicalization on Apache

Oct 30th, 2021 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Requirements to setup IP Canonicalization on Apache web-server:
  2.  
  3. 1) You must require a dedicated IP address.
  4. 2) Add a rewrite rule in .htaccess file.
  5.  
  6. RewriteEngine On
  7. RewriteCond %{HTTP_HOST} ^xxx\.xxx\.xxx\.xxx [nc,or]
  8. RewriteCond %{HTTP_HOST} ^example.\.com [nc]
  9. RewriteRule (.*) http://www.example.com/$1 [R=301,L]
  10.  
  11.  
  12. Second variant:
  13.  
  14. RewriteEngine on
  15. RewriteCond %{HTTP_HOST} ^xxx\.xxx\.xxx\.xxx$
  16. RewriteRule .* https://example.com [R,L]
  17.  
  18. Replace xxx\.xxx\.xxx\.xxx with your dedicated IP address and replace example.com with your actual domain name.
  19.  
  20. You can test it:
  21. https://seomator.com/free-tools/ip-canon-test
  22.  
Advertisement
Add Comment
Please, Sign In to add comment