Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, I want to create an htaccess file which allows specified ip(s) to show content on web-site, if ip is not listed than redirects it to another webpage url. I am trying to use this to building up my website. I will be able to create my website and view it while other users see under construction page. Here is what I am trying:
order deny,allow
deny from all
allow from 888.888.888.888
I got it but do not how to redirect un-listed ip's to an url or a subdomain.
I found and tested, it works. If someone needs something like this here it is:
Edit url and Copy paste it to your .htaccess file
# redirect all visitors to alternate site but retain full access for you
ErrorDocument 403 http://www.xxx.com # non authorized ip's redirected to this url
Order deny,allow
Deny from all
Allow from xx.xx.xx.xx # allowed ip adress
Hey, I can't redirect a subdomain with using this htaccess configuration, any suggestions?
# redirect all visitors to alternate site but retain full access for you
ErrorDocument 403 http://www.xxx.com # non authorized ip's redirected to this url
Order deny,allow
Deny from all
Allow from xx.xx.xx.xx # allowed ip adress
If the .htaccess is in the server's docroot and the subdomain's docroot is a subdirectory of it, then it should work.
BTW as an alternative, you can use mod_rewrite:
Code:
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^xx.xx.xx.xx
RewriteRule (.*) http://www.xxx.com [R=302]
I want to access web-site with my ip, and let all other visitors redirect to subdomain for example: comingsoon.xxx.com so when non-authorized ip visits xxx.com he will redirected to comingsoon.xxx.com
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.