[MediaWiki-l] Rewrite Rules

Daniel Friesen daniel at nadir-seen-fire.com
Wed Jan 16 04:33:38 UTC 2013


On Sat, 12 Jan 2013 17:17:41 -0800, Mark A. Hershberger  
<mah at everybody.org> wrote:

> On 01/12/2013 08:03 PM, Steve VanSlyck wrote:
>
>> # Short url for wiki pages(dunno if [PT,L] is required instead)
>> RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L]
>> # Redirect / to Main Page(dunno if [PT,L] is required instead)
>> RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
>
> %{DOCUMENT_ROOT} is wrong there.
>
> Try replacing those lines with this:
>
>   RewriteCond %{REQUEST_FILENAME} !-f
>   RewriteRule ^/?wiki/(.*)$ /wiki/index.php?title=$1 [L,QSA]
>   RewriteRule ^/*$ /wiki/Main_Page [L,QSA]
>
> HTH,
>
> Mark.
>

Ugh... I wish I had seen this before.
This advice is completely off.
%{DOCUMENT_ROOT} is not wrong. Though /w/ is. And that ?title=$1 shouldn't  
be there.

The proper rules are:

RewriteEngine On

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

-- 
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]




More information about the MediaWiki-l mailing list