Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am using mediawiki on my localhost server. my url for now is

But i want to convert above mentioned url to wiki. or something like wiki.nikunj.com if my wiki is url is www.nikunj.com/wiki

I read this article http://www.mediawiki.org/wiki/Manual:Short_URL but not able to achieve it.

They have given how to convert www.example.com to wiki.example.com but using Lighthttpd.

here is the code:

$HTTP["host"] == "wiki.example.com" {
server.document-root = "/path/to/webroot"
url.rewrite-once = (
"(^/[^:]*[\./].*)" => "$1",
"^/([^?]*)(?:\?(.*))?" => "/w/index.php?title=$1&$2",

Also i have a website like www.nikunj.com. There i installed wiki to www.nikunj.com/wiki, now i want to port it to wiki.nikunj.com

I tried this but it doesn't worked.

With mod_rewrite:

<VirtualHost *:80>
ServerName wiki.nikunj.com
RewriteEngine on
RewriteRule ^/(.*) http://www.nikunj.com/wiki/$1 [R,L]

With mod_alias:

<VirtualHost *:80>
ServerName wiki.nikunj.com
RedirectMatch ^/(.*) http://www.nikunj.com/wiki/$1

But is is not working please, help me out.

share|improve this question

1 Answer 1

Lighthttpd url.rewrite-once rewrites URLs internally. The Apache configuration code you proposed would serve to redirect, in both cases.

For explanation of lighttpd code: http://redmine.lighttpd.net/projects/1/wiki/Docs_ModRewrite#urlrewrite-once

You actually do not need to do anything special to use wiki.nikunj.com instead of nikunj.com . Simply use the ServerName and DocumentRoot directives like for any VirtualHost.

If your MediaWiki files live at /path/to/webroot/wiki, then your DocumentRoot directive would read like the example below:

<VirtualHost *:80>
ServerName wiki.nikunj.com
DocumentRoot /path/to/webroot/wiki


You will also need to add MediaWiki's suggested Apache rewrite code: http://www.mediawiki.org/wiki/Manual:Short_URL/Apache

With the above code, where wiki.nikunj.com uses /path/to/webroot/wiki , you will need to include this rewrite code, either in /path/to/webroot/wiki/.htaccess or in the above VirtualHost block.

## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ /index.php [L]
RewriteRule ^/*$ /index.php [L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.