Redirect a specific IP address to a special page of my homepage with .htaccess

后端 未结 2 1958
死守一世寂寞
死守一世寂寞 2021-01-22 00:07

How can I use .htaccess to forward a visitor of a specific IP address to a webpage on my server?

This example causes an infinite loop:

RewriteCond %{REMO         


        
相关标签:
2条回答
  • 2021-01-22 00:56

    Add a condition to not rewrite when you're already at specialpage:

    RewriteCond %{REMOTE_ADDR} ^123\.\123\.123\.123$
    RewriteCond %{REQUEST_URI} !/specialpage.php
    RewriteRule ^(.*)$ /specialpage.php [R,L] 
    
    0 讨论(0)
  • 2021-01-22 01:04

    Just figured out the solution:

    RewriteCond %{REMOTE_ADDR} ^123\.\123\.123\.123$
    RewriteCond %{REQUEST_URI} !/specialpage.php
    RewriteRule .*\.(htm|html|php)$ /specialpage.php [R,L]
    

    Thank you for your help!

    0 讨论(0)
提交回复
热议问题