Rewrite rules

From Wiki2

Why .htaccess won't work

if ALLOW OVERRIDE NONE is anywhere in /etc/apache2/sites-available or /etc/apache/apache2.conf

mediawiki rewrite rules

if you want a setup like http://wiki.sitebuilt.net/Tobin ...

1. create subdomain in /etc/sites-available as in these directions

<VirtualHost *:80>
 ServerName wiki.sitebuilt.net
 DocumentRoot /home/wiki/public_html
 # Other directives here
</VirtualHost>

2. got0 http://shorturls.redwerks.org/ and follow the directions which ends up with in /etc/sites-available/wiki add

   RewriteEngine On
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
   RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/wiki/index.php [L]
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
   RewriteRule ^/?wiki/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/wiki/thumb.php?f=$1&width=$2 [L,QSA,B]
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
   RewriteRule ^/?wiki/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/wiki/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

and at the bottom of localsettings.php add

 $wgScriptPath = "/wiki";
 $wgScriptExtension = ".php";
 $wgArticlePath = "/$1";

Setup rest rewrite rules

Add rewrite rules[edit] so a restful path /hsc/feeds/1234 (which doesn't really exist) sends you to the API which processes the request using the /feeds/12345 information from the path. load rewrite extension

sudo a2enmod rewrite
/usr/sbin/apache2ctl restart

In /etc/apache2/sites-available/default add rules like

   <Directory /var/www/hsc>
   	RewriteEngine On
   	RewriteRule feed/([0-9]+) /var/www/hsc/index.php?id=$1
   	RewriteRule feeds /var/www/hsc/index.php
   	RewriteRule datastreams /var/www/hsc/index.php?id=$1	
   	RewriteRule prog /var/www/hsc/index.php?id=$1		
   	RewriteRule progs /var/www/hsc/index.php?id=$1		
   </Directory>

remember to restart apache

  /usr/sbin/apache2ctl restart