MultiTikiWiki sites handling under subdirectories

Using a single web hosting account to host multiple sites

MultiTikiWiki sites handling under subdirectories

Postby xavi » Mon Oct 09, 2006 1:25 am

Hi:

I'm using mod-rewrite without problems to rewrite long url's on TikiWiki based CMS sites (http://tikiwiki.org), with single or multitiki installation from the same folder in the file tree on the server, each of them configured with a different domain using virtual hosts (http://domain.com , http://whatever.domain.com , http://www.anotherdomain.com , ...)

All of them rely on the installation on /home/httpd/tiki19dns/

However, when I install multitikis as subdirectories (http://www.domain.com/site1/ , http://www.domain.com/site2/ , http://www.domain.com/site3/ ...), and being the installation on /home/httpd/tiki19/ , url's are not rewritten properly.

Apache gets the url from /etc/apache/httpd.conf , which contains:

Code: Select all
Alias /site1 "/home/httpd/tiki19"
<Directory "/home/httpd/tiki19">
    Options Indexes
     AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Alias /site2 "/home/httpd/tiki19"
<Directory "/home/httpd/tiki19">
    Options Indexes
     AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Alias /site3 "/home/httpd/tiki19"
<Directory "/home/httpd/tiki19">
    Options Indexes
     AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


On that directory under the file tree I put the .htaccess file.
(/home/httpd/tiki19/.htaccess)

This file contains:
("site1" is called "cursos" in our file)

Code: Select all
<FilesMatch "\.(bak|inc|lib|sh|tpl)$">
   order deny,allow
   deny from all
</FilesMatch>

<Limit GET POST PUT DELETE>
order deny,allow
allow from all
</Limit>

<IfModule mod_rewrite.c>
   RewriteEngine On
   
   # direct one-word access
   RewriteRule   ^articles$             /cursos/tiki-view_articles.php                   [L]
   RewriteRule   ^blogs$                /cursos/tiki-list_blogs.php                      [L]
   RewriteRule   ^categories$           /cursos/tiki-browse_categories.php               [L]
   RewriteRule   ^charts$               /cursos/tiki-list_charts.php                     [L]
   RewriteRule   ^chat$                 /cursos/tiki-chat.php                            [L]
   RewriteRule   ^contact$              /cursos/tiki-contact.php                         [L]
   RewriteRule   ^directories$          /cursos/tiki-directory_browse.php                [L]
   RewriteRule   ^eph$                  /cursos/tiki-eph.php                             [L]
   RewriteRule   ^faqs$                 /cursos/tiki-list_faqs.php                       [L]
   RewriteRule   ^files$                /cursos/tiki-file_galleries.php                  [L]
   RewriteRule   ^forums$               /cursos/tiki-forums.php                          [L]
   RewriteRule   ^images$               /cursos/tiki-galleries.php                       [L]
   RewriteRule   ^galleries$            /cursos/tiki-galleries.php                       [L]
   RewriteRule   ^games$                /cursos/tiki-list_games.php                      [L]
   RewriteRule   ^my$                   /cursos/tiki-my_tiki.php                         [L]
   RewriteRule   ^newsletters$          /cursos/tiki-newsletters.php                     [L]
   RewriteRule   ^quizzes$              /cursos/tiki-list_quizzes.php                    [L]
   RewriteRule   ^stats$                /cursos/tiki-stats.php                           [L]
   RewriteRule   ^surveys$              /cursos/tiki-list_surveys.php                    [L]
   RewriteRule   ^trackers$             /cursos/tiki-list_trackers.php                   [L]
   RewriteRule   ^irc$                  /cursos/tiki-irc_logs.php                        [L]
   RewriteRule   ^sheets$               /cursos/tiki-sheets.php                          [L]
   RewriteRule   ^workspaces$           /cursos/tiki-workspaces_admin.php                [L]

   # access any object by its numeric identifier
   RewriteRule   ^article([0-9]+)     /cursos/tiki-read_article.php?articleId=$1       [QSA,L]
   RewriteRule   ^art([0-9]+)         /cursos/tiki-read_article.php?articleId=$1       [QSA,L]
   RewriteRule   ^blog([0-9]+)        /cursos/tiki-view_blog.php?blogId=$1             [QSA,L]
   RewriteRule   ^chart([0-9]+)       /cursos/tiki-view_chart.php?chartId=$1           [QSA,L]
   RewriteRule   ^cat([0-9]+)         /cursos/tiki-browse_categories.php?parentId=$1   [QSA,L]
   RewriteRule   ^categ([0-9]+)       /cursos/tiki-browse_categories.php?parentId=$1   [QSA,L]
   RewriteRule   ^directory([0-9]+)   /cursos/tiki-directory_browse.php?parent=$1      [QSA,L]
   RewriteRule   ^eph([0-9]+)         /cursos/tiki-directory_browse.php?parent=$1      [QSA,L]
   RewriteRule   ^faq([0-9]+)         /cursos/tiki-view_faq.php?faqId=$1               [QSA,L]
   RewriteRule   ^file([0-9]+)        /cursos/tiki-list_file_gallery.php?galleryId=$1  [QSA,L]
   RewriteRule     ^dl([0-9]+)          /cursos/tiki-download_file.php?fileId=$1         [QSA,L]
   RewriteRule   ^forum([0-9]+)       /cursos/tiki-view_forum.php?forumId=$1           [QSA,L]
   RewriteRule   ^poll([0-9]+)        /cursos/tiki-poll_results.php?pollId=$1          [QSA,L]
   RewriteRule   ^vote([0-9]+)        /cursos/tiki-poll_form.php?pollId=$1             [QSA,L]
   RewriteRule   ^img([0-9]+)         /cursos/tiki-show_image.php?id=$1                     [QSA,L]
   RewriteRule   ^image([0-9]+)       /cursos/tiki-browse_image.php?imageId=$1         [QSA,L]
   RewriteRule   ^gallery([0-9]+)     /cursos/tiki-browse_gallery.php?galleryId=$1     [QSA,L]
   RewriteRule   ^gal([0-9]+)         /cursos/tiki-browse_gallery.php?galleryId=$1     [QSA,L]
   RewriteRule   ^newsletter([0-9]+)  /cursos/tiki-newsletters.php?nlId=$1             [QSA,L]
   RewriteRule   ^quiz([0-9]+)        /cursos/tiki-take_quiz.php?quizId=$1             [QSA,L]
   RewriteRule   ^survey([0-9]+)      /cursos/tiki-take_survey.php?surveyId=$1         [QSA,L]
   RewriteRule   ^tracker([0-9]+)     /cursos/tiki-view_tracker.php?trackerId=$1       [QSA,L]
   RewriteRule   ^irc([0-9]+)         /cursos/tiki-irc_logs.php?focus=$1               [QSA,L]
   RewriteRule   ^demo([0-9]+)        /cursos/tiki-demo.php?demoId=$1                  [QSA,L]
   RewriteRule   ^decide([0-9]+)      /cursos/tiki-demo.php?demoId=$1                  [QSA,L]
   RewriteRule   ^int([0-9]+)         /cursos/tiki-integrator.php?repID=$1             [QSA,L]
   RewriteRule   ^sheet([0-9]+)       /cursos/tiki-view_sheets.php?sheetId=$1          [QSA,L]
   RewriteRule   ^ws([0-9]+)          /cursos/tiki-workspaces_desktop.php?workspaceId=$1    [QSA,L]

   # todo add support for all characters allowed in a Wiki name
   # make sure this is the last rule!
   RewriteRule   ^show:(~?)([-_\+A-Za-z0-9]+)$  /cursos/tiki-slideshow.php?page=$1$2   [QSA,L]
   RewriteRule   ^(~?)([-_\+A-Za-z0-9]+)$    /cursos/tiki-index.php?page=$1$2          [QSA,L]

   #for multi-byte char support use
   RewriteRule     ^([^a-z]+)([^\/]+)([^tki-]+)(.*[^.js]+)(~?)(.*)$ /cursos/tiki-index.php?page=$1$2$3$4$5$6$7$8$9 [QSA,L]

</IfModule>


Url of the site is:
http://moviments.net/cursos

And url's are not being rewritten properly.

Any hints on how to achieve that url's are rewritten properly?


On the contrary, on the main site of our server:
http://moviments.net

url's are rewritten properly with a similar .htaccess file (without the "cursos/" part, of course)[/code]
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am

Postby richardk » Mon Oct 09, 2006 10:12 am

You need to setup a RewriteBase for Aliases, but you can't if multiple sites use the same .htaccess file. Maybe you could use a symlink.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xavi » Mon Oct 09, 2006 10:43 am

How to use a symlink in this context to solve it?

Delete aliases in apache conf and use a real ./htdocs/site1/ symlink to /home/httpd/tiki19/ ?

Where should I put this .htaccess file then?
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am

Postby richardk » Tue Oct 10, 2006 8:56 am

Delete aliases in apache conf and use a real ./htdocs/site1/ symlink to /home/httpd/tiki19/ ?

Try it.

Where should I put this .htaccess file then?

Where it is now. /home/httpd/tiki19/.htaccess
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

half solved! (thanks), next question for the other half

Postby xavi » Wed Oct 11, 2006 1:34 am

Ouau, getting close! :-)
Symlink-approach works fine (provided that I include a copy of all rewrite rules for each tiki of the multitiki installation, I guess). I've tried with just one, and it worked (rewriting urls as expected, etc.).

However, there is one drawback (I don't know how to solve it):
When the url is written without the slash at the end (i.e.: http://movimens.net/cursos ) then the user is sent to the page "cursos" on the parent Tiki (http://moviments.net), which also has an .htaccess file with its own rewrite rules. So that it's trying to access the page "cursos" under moviments.net, which is the equivalent to:
http://moviments.net/tiki-index.php?page=cursos

QUESTION:
Can I add another rule at http://moviments.net/.htaccess (/home/httpd/htdocs/.htaccess) so that whenever somebody attemps to visit url
http://moviments.net/cursos

it's not redirected to:

http://moviments.net/tiki-index.php?page=cursos

but to

http://moviments.net/cursos/

?

(which would allow the symlink to work and do the rest)
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am

Re: half solved! (thanks), next question for the other half

Postby xavi » Wed Oct 11, 2006 1:54 am

xavi wrote: So that it's trying to access the page "cursos" under moviments.net, which is the equivalent to:
http://moviments.net/tiki-index.php?page=cursos


In fact this is not true. The page displayed was another one.
I've re-set the httpd.conf with the alias since this is aproduction site, and many people have the link without the ending slash.
If you now the answer to the previous question (or any other hack to solve it), I'll apply it very happyly to our sites... :-)
(thanks for feedback so far, anyway :-)
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am

Postby richardk » Wed Oct 11, 2006 6:34 am

You could try:
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xavi » Thu Oct 12, 2006 7:46 am

richardk wrote:You could try:
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]


Nearly, Using this I get that this address:
http://moviments.net/cursos

is rewritten to:
http://moviments.net/cursos/

(which was the pursued behavior)

But also (undesired behavior):
http://moviments.net/cursos/forums

is rewritten as:
http://moviments.net/cursos/forums/

which doesn't exist.

which is the best solution, then?
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am

Postby richardk » Thu Oct 12, 2006 8:47 am

Code: Select all
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Thanks! :-)

Postby xavi » Sun Oct 15, 2006 1:08 am

FINALLY! It does work! :D
Thanks you very much, Richard.

BTW: How do you know so much about mod_rewrite? (are you apache coder or similar?)
Anyways, thanks a lot! :P
xavi
 
Posts: 11
Joined: Fri May 19, 2006 10:19 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 13 guests

cron