I have set up a subdomain of my site (for the purposes of this question I'll call it wiki.example.com), installed a wiki there, and set up URL rewrite according to the article on MediaWiki's website (http://www.mediawiki.org/wiki/Manual:Short_URL/Apache).

But because my subdomain is purely dedicated to the wiki I was hoping that I could have my URLs in the format wiki.example.com/ArticleName rather than wiki.example.com/wiki/ArticleName.

I tried this by modifiying the rewrite rule in a way I thought would be correct:

RewriteRule ^(/.*)$ %{DOCUMENT_ROOT}/index.php [L]

Disclaimer: it may not have been exactly like that as the syntax I had written is no longer available for me to retype into this question.

This partially worked, as I could reach the page at wiki.example.com/Main_Page but none of the images or CSS had loaded.

I suspect the URL rewrite rule was trying to point everything at index.php but I'm wondering if there's any way to get a URL in the format wiki.mysite.com/ArticleName?

  • Just .htaccess is not enough, afaik. Did you check LocalSettings.php file?
    – rush
    Mar 29, 2014 at 14:52
  • I did make the necesary changes to LocalSettings.php. To be clear - I did get the 'normal' rewrite working, but I'm trying to acheive an alternative whereby the article name can be placed directly after the hostname. I did make appropriate changes for this in localsettings.php
    – MrVimes
    Mar 29, 2014 at 16:15

1 Answer 1


The way which I hide that type of issue is by using .htaccess, and it actually works mighty well.

The code comes from my webhost, and you have to make some slight edits to fix it up to work, but it should work for you also.

# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L] 

Basically, it is going to take the /wiki/ folder out of the URL and it should fix your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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