Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Using htaccess to block port in apache?

Is it possible?

share|improve this question

3 Answers 3

No.

In order to have Apache process the .htaccess file's directives the port needed to be open, and a client needed to connect to it.

What you might be looking for is using iptables to block the port.

share|improve this answer

You theoretically CAN use rewrite rules in .htaccess using the %{SERVER_PORT} variable to do something different with requests coming in on a specific port, which could also mean denying access to resources.

However, this is almost certainly not the best way to get to what you're trying to accomplish.

share|improve this answer

please use RewriteCond %{SERVER_PORT} !3306$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.