We should refactor and put this in MoinMaster. If you agree, we can call it HelpOnInstalling/ApacheOnLinuxRootWikiViaFtp or similar.
Root wiki in a shared hosting environment
I have a shared hosting account (technically, a reseller account) on which I host my webpages. I wanted a root wiki in the sense that I wanted people to be able to type in http://www.example.com and see my front page; and all links on the front page should be of the form http://www.example.com/MyLink rather than http://www.example.com/cgi-bin/moin.cgi/MyLink.
This situation is not dealt with in the regular help/install docs, which assume that you have access to the Apache configuration files in order to insert ScriptAlias directives. Related pages are
HelpOnInstalling/ApacheOnLinuxFtp
- exactly this one does not require to edit the configuration file
The following solution comes from Charl Botha, who also commented on this problem in this bug report.
How To
The situation we are faced with is shared hosting (i.e. you don't have access to /etc/apache2/apache2.conf) and we would like URLS of the form http://www.example.com/terry/MyLink (so that our wiki root is http://www.example.com/terry/). Our shared hosting provider has put us in a directory /home/example/ with the DocumentRoot at /home/example/public_html/ and our CGI files, including moin.cgi, are in the directory /home/example/public_html/cgi-bin/. This means that a default installation of MoinMoin would have the ugly URLS like http://www.example.com/cgi-bin/moin.cgi/MyLink.
Using .htaccess tricks alone will not work. Try putting the htdocs into /home/example/public_html/_htdocs, and the following into a file called .htaccess below your DocumentRoot (I put it into /home/example/public_html/terry to get the link named above; if you want a root wiki then substitute '/' for '/terry' wherever it occurs):
RewriteEngine on # The RewriteBase tells Apache that we got here because the user typed in # http://example.com/terry/SomePage, rather than http://example.com/SomePage RewriteBase /terry # If the request is not for a valid directory... RewriteCond %{REQUEST_FILENAME} !-d # ...and it's not for a file... RewriteCond %{REQUEST_FILENAME} !-f # ...then pass the path from the URL to moin.cgi RewriteRule ^(.*) /cgi-bin/moin.cgi/$1 [last,type=application/x-httpd-cgi] # Of course, if the user just typed http://example.com/terry, # that needs to work too! RewriteRule ^$ /cgi-bin/moin.cgi [last,type=application/x-httpd-cgi]
That will almost work: if you go to http://example.com/terry/FrontPage, you will get the page you asked for. However, all the links on that page will be ugly, such as http://example.com/cgi-bin/moin.cgi/RecentChanges. The visitor to your site will be plagued with these unwieldy links, and if they try to use Mozilla's "Copy Link Location" option on the right-click menu, they'll get this link rather than http://example.com/terry/RecentChanges.
There is a wonderfully simple workaround to this: edit moin.cgi so that it contains, somewhere near the top (perhaps just below import sys). the following:
However, according toMehdiHassanpour this generated an "Internal Server Error" on his setup, but the following solution adapted byMarianoAbsatz from the SourceForge setup worked OK for him.
Edit moin.cgi and instead of adding the os.environ['SCRIPT_NAME'] = '/terry' line, replace the line that looks like:
request = RequestCGI()
with:
request = RequestCGI(properties={'script_name':'/terry'})
A variation
The rewrite rules above literally say "if the request is not for an existing file (like those in /htdocs) or an existing directory, we assume that the request should be passed as is to moin.cgi. Another way of doing things is to use the rule "if the request is for something starting with _htdocs then direct it to the relevant file, otherwise anything else is passed to moin.cgi - even if a file of that name exists! This could be done with the following .htaccess:
RewriteEngine on RewriteBase /terry RewriteRule ^_htdocs(.*) /_htdocs$1 [last] RewriteRule ^(.*) /cgi-bin/moin.cgi/$1 [last,type=application/x-httpd-cgi] RewriteRule ^$ /cgi-bin/moin.cgi [last,type=application/x-httpd-cgi]
You have to make a change in wikiconfig.py (or whichever config file you're using), namely setting
1 url_prefix = '/_htdocs'
In the previous example, it didn't matter what this variable was set to: if it pointed to a real file, it would get there.
Discussion
Apparently, you need that the directory has AllowOverride fileinfo for this to work.
It also seems that the virtual host DocumentRoot must be owned by the user running this vhost when this is done via suexec.
How about adding these lines to MoinMaster? (cf. EditingOnMoinMaster).