Rewrite Configuration
This is an old revision of this page, as edited June 11, 2013, 9:16 AM by pegasus(contribs). It may differ significantly from the current revision.
Rewrite rules allow a web server to take incoming requests to files and folders that may not physically exist on your server's file system and map them to scripts capable of handling those requests. With VaultWiki, you may need to update your server's Rewrite Configuration if:If you don't have any catch-all rewrite rules in place, and you are using default values for the following Site Config settings, you can usually skip this step:
- You have installed VaultWiki for the first time
- You have upgraded to VaultWiki 4 from VaultWiki 3
- You have installed a catch-all script after installing VaultWiki
- You have made changes recently to Settings: Site Config.
- Filename of the Wiki PHP File
- Wiki URL Format
Note: The Filename you choose for the Wiki PHP File should not be the name of another existing file, unless it is 'wiki_index' itself. If you are using a non-default setting for the Wiki URL Format, the Filename should not be the name of an existing directory. If the selected Filename matches a location on your server that already exists, it simply cannot point to the wiki too.
Depending on what kind of software your web server uses, the configuration will vary.
Apache
Locate the /.htaccess file in your forum directory or create a new one.
Add the following to the file:
Code:RewriteEngine On
RewriteBase /
# If filename is not 'wiki_index', replace WIKI_FILE and uncomment the following line
# RewriteRule ^WIKI_FILE.php wiki_index.php [L,QSA]
# If URL format is /wiki/path uncomment the following line
# RewriteRule ^yui-combo/([^/]+)/(.+)$ yui_loader.php?v=$1&f=$2 [L,QSA]
# If URL format is /wiki/path or replaces a catch-all rule, uncomment the following 3 lines
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)?$ wiki_index.php [L,QSA]
NginX
Open your /etc/nginx/nginx.conf file for editing, locate the server block for the domain where VaultWiki is installed, and add the following, where /forums/ is your forum directory:
Code:# If filename is not 'wiki_index', replace WIKI_FILE and uncomment the following 3 lines
#location ~ ^/forums/WIKI_FILE\.php$ {
# rewrite ^ /forums/wiki_index.php;
#}
# If URL format is NOT /wiki/path, do NOT include this block
location /forums/ {
if ($request_uri ~ ^/forums/yui-combo/) {
rewrite ^/forums/yui-combo/([^/]+)/(.+)$ /forums/yui_loader.php?v=$1&f=$2 last;
}
# for vBulletin, uncomment the following line
# if ($request_filename !~ /(?:admincp|clientscript|cpstyles|install|images|modcp|cron|vbseo|vault)/)
# for XenForo, uncomment the following line
# if ($request_filename !~ /(?:admin|data|install|js|styles|vault)/)
{
set $redirect_url $fastcgi_script_name;
rewrite ^ /forums/wiki_index.php last;
}
}
Note on Catch-All Rules (like vBSEO)
If you use vBSEO or some other method of catch-all URL rewriting, keep in mind that VaultWiki's rewrite rules should super-cede and completely replace the rules for your existing solution.
If you do not do this, your wiki will be inaccessible and you will just get a "Configuration Error" all the time.
Using the vBSEO example, your .htaccess file might already contain something similar to the following:
Code:RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
This block should be completely commented out or removed, since VaultWiki accomplishes the same thing.
Next you would locate a section that looks like this:
Code:RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
Then, in the part of the line that ends like so:
Code:|api\.php)
you want to add more information right before the closing parenthesis. Usually, the following will be enough:
Code:|wiki|yui
In order for vBSEO to continue doing its original job with these changed rules, you also need to modify vault/config.php. Find the line that defines DEFAULT_SCRIPT, and change it to 'vbseo.php'