1

Is it possible to limit access to the Control Panel to a specific HTTP port, which is shielded from public access? We want external visitors to only be able to access the front end site.

2

First set your web server up so the full website gets loaded from both the external ports (e.g. 80 and 443) as well as your internal port (let's say 9001).

Then open your index.php file, and add this to the top of it:

// Restrict CP access to port 9001
if (
    $_SERVER['SERVER_PORT'] != 9001 && 
    isset($_GET['p']) &&
    preg_match('^\/*admin(\/.*)?$/', $_GET['p'])
) {
    http_response_code(403);
    echo 'You are not authorized to access this area.';
    exit();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.