Dear all,
I've a working Drupal website on my machine with Clean Urls enabled.
I'd like to install a wiki (mediawiki) accessible from http:/myhost/wiki/
wiki never appear as an alias in my Drupal website so there is no conflict between addresses.
I've tried to add an Alias to my apache configuration file,
but whenever I try to go to /wiki I can't because I'm redirected to the Drupal missing page.
Googling I think that the problem could be because of the rewrite reules used for the originary drupal
website, but I have not idea how to modify them to keep drupal working and hosting
a wiki as well.

My conf apache file contains the following:
#this was created for the original drupal installation

DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                RewriteEngine on
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        </Directory>

For the wiki I've added the following:
Alias /wiki/ "/var/mediawiki/"

    <Directory "/var/mediawiki/">     
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
    </Directory>

Do you have any idea how I can fix this?
Any help is appreciated, thank you in advance,
Luca

Comments

PawelR’s picture

Hi Luca,
you can add following two lines after 'RewriteBase /':

RewriteCond %{REQUEST_URI} "/wiki/"
RewriteRule ^(.*)$ wiki/index.php?q=$1 [L]

assuming that there is a 'index.php' file in the '/wiki' directory which routes all requests for this application.

This rewrite rule will pass 'q' variable with the requested path to /wiki/index.php file.

lucacerone’s picture

Hi Pawell,
thanks for your help.
I've not access to the machine so I can't test it now, but I'll let you know.
Just for knowledge, what does this rewrite rule does?
(as far as I have understood, it takes everything after: myhost/wiki/ and uses it
as input for the index.php that is in the wiki folder, right?
What if I want to have access to a page like myhost/wiki/README.txt ?
(it's just an example, I don't really know if I'll need something like this or not :))
How can I make the whole myhost/wiki/ behave as if it would be a neew root?

Thanks a lot again for your help :)
Cheers, -Luca

PawelR’s picture

Hi Luca,
it sets suberglobal variable $_GET['q'] which contains string what user typed in. The code in index.php can decide what to do with this information, for example if the path is /user/1 the code can decide to use function 'user' and pass value 1 to this function and this function will return response to the browser.

you should be able to access any files and directories within your listed settings, those lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

in your conf file are the condition to don't execute next line:

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

'!-f' and '!-d' means no files and directories.

Basically if the requested path doesn't exist in file system then rewrite rule is applied and everything what user has typed in URL input box is passed to index.php file and is accessible using $_GET['q'].

If you mean redirection to var/www/wiki/ if somebody will type http://yourhost/ ?

if yes, then you can just set document root for yourhost to var/www/wiki but if your Drupal installation is on var/www then it will not be accessible directly by HTTP requests, only the content of var/www/wiki and sub folders will be accessible directly from outside.

lucacerone’s picture

Hi,
I could manage to make it work adding an alias and the following directives
to my conf file!
Is there any drawback in what I did?
Thanks a lot in advance :)

Alias /wiki "/var/wiki"
<Directory "/var/wiki">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order Allow,Deny
    Allow from all
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /wiki/index.php?q=$1 [L,QSA]
</Directory>