An example of rewrite rules for Shinobu 0.2.
Shinobu supports URL rewriting. This document gives some examples of rewrite rules for Apache and LightTPD.
Before you can use Shinobu's rewrite engine you have to enable it in the configuration file [shinobu root]/system/core/sample.config.php. For more information
about this take a look at the documentation of Shinobu's configuration file here.
Apache rewrite rules are defined in a .htaccess file. Shinobu already ships with an example .htaccess.apache located in the root of your Shinobu installation
[shinobu root]/htacces.apache.
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options -MultiViews
Options +FollowSymLinks
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine on
# Path to the shinobu folder
# RewriteBase /path/to/shinobu/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^admin/(.*)$ admin/index.php?q=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?q=$1 [L]
</IfModule>
LightTPD rewrite rules are set in the LightTPD configuration file. On most UNIX like operating systems this file is located in /etc/lighttpd/lighttpd.conf.
If you do not have access to this file contact your ISP for help on this.
An example of global rewrite rules.
url.rewrite-once = (
"^/admin/themes/(.*)$" => "/admin/themes/$1",
"^/admin/js/(.*)$" => "/admin/js/$1",
"^/admin/?$" => "/admin/index.php",
"^/admin/(.*)$" => "/admin/index.php?q=$1",
"^/themes/(.*)$" => "/themes/$1",
"^/?$" => "/index.php",
"^/([^?](.*?))$" => "/index.php?q=$1"
)
Another example for if Shinobu is located in a subdirectory of your website. E.g. http://www.example.com/subdir.
url.rewrite-once = (
"^/subdir/admin/themes/(.*)$" => "/subdir/admin/themes/$1",
"^/subdir/admin/js/(.*)$" => "/subdir/admin/js/$1",
"^/subdir/admin/?$" => "/subdir/admin/index.php",
"^/subdir/admin/(.*)$" => "/subdir/admin/index.php?q=$1",
"^/subdir/themes/(.*)$" => "/subdir/themes/$1",
"^/subdir/?$" => "/subdir/index.php",
"^/subdir/([^?](.*?))$" => "/subdir/index.php?q=$1"
)
And an example of host based rewrite rules.
$HTTP["host"] =~ "www.example.com" {
server.document-root = "/path/to/site/"
url.rewrite-once = (
"^/admin/themes/(.*)$" => "/admin/themes/$1",
"^/admin/js/(.*)$" => "/admin/js/$1",
"^/admin/?$" => "/admin/index.php",
"^/admin/(.*)$" => "/admin/index.php?q=$1",
"^/themes/(.*)$" => "/themes/$1",
"^/?$" => "/index.php",
"^/([^?](.*?))$" => "/index.php?q=$1"
)
}
This are some example rules if you are using Shinobu with Nginx.
rewrite ^(/)themes/(.*?)$ $1themes/$2 break;
rewrite ^(/)static/(.*?)$ $1static/$2 break;
if (!-e $request_filename) {
rewrite ^(/)$ $1index.php last;
rewrite ^(/)(.*?)$ $1index.php?q=$2 last;
}
location /admin/ {
rewrite ^(/admin/)themes/(.*?)$ $1themes/$2 break;
rewrite ^(/admin/)js/(.*?)$ $1js/$2 break;
if (!-e $request_filename) {
rewrite ^(/admin/)$ $1index.php last;
rewrite ^(/admin/)(.*?)$ $1index.php?q=$2 last;
}
}