## page was renamed from RobertSchumann/ApacheOnLinuxFTP '''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 * HelpOnConfiguration/ApacheVoodoo * ApacheConfigExamples * ThiloPfennig/ExperiencesWithApacheOnLinuxFtp * [[http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html|Apache 1.3 mod_rewrite docs]] or [[http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html|Apache 2 mod_rewrite docs]] The following solution comes from [[http://cpbotha.net/AboutThisSite|Charl Botha]], who also commented on this problem in [[MoinMoinBugs/URLMappingsCausesTraceback|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 D''''''ocumentRoot 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 D''''''ocumentRoot (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: {{{#!python import os os.environ['SCRIPT_NAME'] = '/terry'}}} However, [[http://sourceforge.net/mailarchive/message.php?msg_id=15261815|according to ]]MehdiHassanpour this generated an "Internal Server Error" on his setup, but the following solution [[http://sourceforge.net/mailarchive/message.php?msg_id=15257468|adapted by ]]MarianoAbsatz 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 {{{#!python 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 = [[http://sourceforge.net/mailarchive/message.php?msg_id=15260065|Apparently]], you need that the directory has {{{AllowOverride fileinfo}}} for this to work. [[http://sourceforge.net/mailarchive/message.php?msg_id=15258733|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).