Reputation:
I have a MediaWiki 1.32.0 website. MediaWiki website directories contains the file LocalSettings.php
in which one could write global custom PHP.
As a non PHP programmer I ask if there is some PHP command I could use to restrict access to a certain existing webpage, by that webpage's URL, so that any web request to create it('s HTML) would be denied, either resulting in some 404-like HTTP status code, or a redirection to homepage, as long as that command appears in LocalSettings.php
?
I would prefer a PHP way instead an Apache PCRE directive in .htacess
. Also, I should note that the URL is already blocked by robots.txt
.
Upvotes: 1
Views: 77
Reputation: 127
You can get the requested URL in PHP like this:
$_SERVER['REQUEST_URI'];
And deny access to a page like this:
$url = $_SERVER['REQUEST_URI'];
if ($url == "/wiki/blocked_page") die('404 error here');
Or redirect to your home page like this:
$url = $_SERVER['REQUEST_URI'];
if ($url == "/wiki/blocked_page") header('Location: /');
Note: request_url is everything after your domain name. If your URL is https://example.com/wiki/blocked_page request_url would return "/wiki/blocked_page".
Upvotes: 1