Zane Posted November 8, 2005 Share Posted November 8, 2005 another question Is it possible to popup an htaccess logon box for when someone tries to access a certain port number So if someone tries to access stuff on port 8080 how do I restrict and authorize it and I guess my next problem would be how do I distinguish in Apache which port a folder is part of if I have all my folders in htdocs (the web root) and I want say my images folder on port 8080 would I have to take it out the web root and put it in a folder in the apache root somewhere....what how you see what I'm getting at? Quote Link to comment Share on other sites More sharing options...
shoz Posted November 10, 2005 Share Posted November 10, 2005 Is it possible to popup an htaccess logon box for when someone tries to access a certain port number If you use a VirtualHost you can add the directives for basic authentication <VirtualHost host:8080> AuthType Basic AuthName images AuthUserFile /path/to/pass_file require valid-user </Virtualhost> how do I distinguish in Apache which port a folder is part of if I have all my folders in htdocs (the web root) and I want say my images folder on port 8080 In a .htaccess file in your root you could have the following RewriteCond %{SERVER_PORT} !=8080 RewriteRule ^images/ - [F] You should be able to use the following inside the VirtualHost directive to have the same VHost settings applied for access on the different ports. However, the %{SERVER_PORT} variable seems to be incorrectly filled with the port listed first in the directive. <VirtualHost host:80 host:8080> </VirtualHost> I had to put multiple VHost directives for the port listed in %{SERVER_PORT}to be accurate. I haven't checked what happens in Apache 2.0, and I'm not using the most recent versions of either. It may ultimately be better to put a section in the Vhost for port 80 to deny access to the directory instead of using the .htaccess file. EDIT: Apache 2.0 apparently has the correct SERVER_PORT value when you use the Multiple listings of host:port in the Virtualhost. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.