Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question

migrated from unix.stackexchange.com Mar 31 at 19:37

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems..

    
Just .htaccess is not enough, afaik. Did you check LocalSettings.php file? –  rush Mar 29 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 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.

share|improve this answer

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.