Custom Httpd Configuration > blocking /phpmyadmin with custom entries

lukgier

Verified User
Joined
Mar 16, 2025
Messages
31
Hi,

When I add blocking /phpmyadmin for only for one domain in custom httpd configuration like this:

httpd > custom 1

Code:
<Location /phpMyAdmin>

    Require all denied

</Location>

nginx > custom 3

Code:
location = /phpMyAdmin {

    return 403;

}

location ^~ /phpMyAdmin/ {

    return 403;

}

I get Forbidden - You don't have permission to access this resource. for all domains on server for */phpmyadmin urls:

Code:
curl -I -H "Host: localhost" http://127.0.0.1:8080/phpMyAdmin/

HTTP/1.1 301 Moved Permanently

Date: Fri, 24 Oct 2025 15:01:14 GMT

Server: Apache/2

Location: https://localhost/phpMyAdmin/

Content-Type: text/html; charset=iso-8859-1

Why doesn't it work like this? I just want to block /phpmyadmin for some domains?

Cheers,
Luke
 
Last edited:
Hello,

httpd > custom 1

The section "Custom 1" goes outside of a VirtualHost context, hence it effects the server globally. You might try "Custom".

nginx > custom 3

I did not try it on my end. I believe NGINX will report a duplicated location and returns an error if you add the things the way you posted here. Correct me if I'm wrong please.
 
Hello,



The section "Custom 1" goes outside of a VirtualHost context, hence it effects the server globally. You might try "Custom".



I did not try it on my end. I believe NGINX will report a duplicated location and returns an error if you add the things the way you posted here. Correct me if I'm wrong please.

Thank you, I will try and let you know if it works.

Is there any other way to block /phpmyadmin for particular domains?
 
Yes, there is:

- ModRewrite for Apache, can be added in /etc/httpd/conf/extra/httpd-includes.conf
- If-statements for Nginx, can be added in /etc/nginx/webapps.conf /etc/nginx/webapps.ssl.conf

consider a correct way for a customization

Related:

- https://docs.directadmin.com/webservices/apache/customizing.html
- https://docs.directadmin.com/webservices/nginx_apache/customizing-nginx-apache.html
- https://docs.directadmin.com/webservices/nginx/customizing-nginx.html
Thank you so much, appreciate this :)
 
Back
Top