User:Woozle/mod rewrite

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search

Where the URL is https://vbz.net/wiki (later note: actually, I may have been requesting https://vbz.net/mw unintentionally) and the rewrite rule is in [docroot]/.htaccess:

  • RewriteRule ^wiki(.+)$ /mw/index.php/?title=$1 [L,QSA]
    • result: GET /mw/:///wiki/Main_Page
  • RewriteRule ^wiki(.+)$ /mw/$1 [L,QSA]
    • result: GET /mw/:///wiki/Main_Page
  • RewriteRule ^wiki(.+)$ /mw [L,QSA]
    • result: GET /mw/:///wiki/Main_Page
  • No RewriteRule at all
    • result: GET /mw/:///wiki/Main_Page

Okay, so apparently .htaccess is disabled... going to VirtualHost.

No, wait... .htaccess works on cloud2, and it also uses VirtualMin. Copying example from there (HypertWiki)...

<apache> RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/mw/index.php [L] # Redirect / to Main Page RewriteRule ^/*$ %{DOCUMENT_ROOT}/wiki/index.php [L]</apache>

Result: https://vbz.net/wiki/:///wiki/:///wiki////wiki/:///wiki////wiki/:///wiki [...]

Removing the second RewriteRule results in "You don't have permission to access /wiki/ on this server."

Fixing the folder permissions does not change this.

Changing the second rewrite rule: <apache> RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/mw/index.php [L] # Redirect / to Main Page RewriteRule ^/*$ %{DOCUMENT_ROOT}/mw/index.php [L]</apache>

...and we're back to https://vbz.net/wiki/:///wiki/:///wiki////wiki/:///wiki////wiki/:///wiki////wiki [...] again.

Changing it again: <apache> RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/mw/index.php [L] # Redirect / to Main Page RewriteRule ^/wiki*$ %{DOCUMENT_ROOT}/mw/index.php [L]</apache>

...takes us back to "You don't have permission to access /wiki/ on this server."

This script proved to be illuminating: <php><?php

echo '

';
print_r($_SERVER);</php>
Note especially REQUEST_URI (/wiki/) and SCRIPT_NAME (/mw/index.php). So this is redirecting the request to the proper script. Maybe MediaWiki is misconfigured?

Why didn't we regen the LocalSettings.php file in the first place? Oh, because we didn't upgrade. We should have upgraded. Let's do that. ...and, the hell, let's just make /wiki a link to /mediawiki-1.28.0 instead of futzing around with .htaccess.