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

I am using mediawiki on my localhost server. my url for now is 127.0.0.1:8080/wiki/index.php/Main_Page

But i want to convert above mentioned url to wiki.127.0.0.1:8080 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]
</VirtualHost>

With mod_alias:

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

But is is not working please, help me out.

share|improve this question
add comment

1 Answer

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
</VirtualHost>

+++++

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
add comment

Your Answer

 
discard

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.