Topic on Manual talk:Short URL/Apache

Using .htaccess to remove a range of subdirs

1
Vicarage (talkcontribs)

(No luck on main mediawiki support desk)

I want to use replace an existing website with mediawiki, but to preserve incoming links I need to remove some path names using .htaccess

So https://subbrit.org.uk/sites/fan-bay-deep-shelter should become https://subbrit.org.uk/fan-bay-deep-shelter, ditto features and a few more

I already use the shortURL logic to shorten paths

LocalSettings.php

$wgScriptExtension = ".php";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
$wgScriptPath = "";

.htaccess

RewriteEngine On 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d 
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]

But my attempts to add new rules like

RewriteRule ^sites/(.*)$ /$1 [R]

just don't take effect, it just asks if I want to create a new page Sites/fan-bay-deep-shelter. The rules do work on the server away from the wiki area. I worry that I'm just changing the URL, but mediawiki is working onm the underlying URI which is not changing

Reply to "Using .htaccess to remove a range of subdirs"