[PATCH] Small kluge for easier mod_rewrite integration
"Malte S. Stretz" <[email protected]> Sun, 17 Oct 2004 18:02:56 +0200
| Newsgroups | gmane.comp.web.wiki.moin.devel |
|---|---|
| Organization | <http://msquadrat.de> |
| Message-ID | <[email protected]> |
And hello again,
as the url_mappings feature didn't do what I intended to do -- have a user
website transparently fed from a Wiki like <http://example.com/WikiSandBox>
but only with .htaccess so no ScriptAlias possible -- I tried to tell Moin
which root it should use. According to the hack posted in [1] and the
unanswered question on [2] does one have to do some patching to get that to
work.
With some black mod_rewrite magic it's possible to feed the script a
different SCRIPT_NAME; unfortunately does the rewrite process prepend the
string REDIRECT_ to the environment variable. The attached patch makes
moin.cgi use that var if its defined.
This works for me with the following .htaccess:
| RewriteEngine On
| RewriteBase /~mss
|
| # The *-bin directories (like cgi-bin, wiki-bin, image-bin, ...) shall not
| # be touched by any following rewriting rules.
| RewriteCond %{REQUEST_URI} /[a-z]+-bin/
| RewriteRule ^ - [last]
|
| # Now the Wiki-rewriting...
| #
| # Strip trailing slashes -- they are good for directories but not for Wiki
| # names.
| RewriteRule ^(.*)/(\?.*)?$ $1$2 [last,redirect=permanent]
| # Transparent access to the Wiki pages; set the SCRIPT_NAME environment
| # variable so moin.cgi know where to link to.
| RewriteRule ^(.*)$ cgi-bin/moin.cgi/$1 [env=SCRIPT_NAME:/~mss]
I guess the even cleaner solution would be to introduce a new config
variable like wiki_prefix -- but for now the attached solution was easier
to implement for somebody like me who doesn't know much about Python and
even less about the MoinMoin internals :)
Cheers,
Malte
[1]http://sourceforge.net/mailarchive/forum.php?thread_id=15110&forum_id=623
[2]http://moinmoin.wikiwikiweb.de/MoinMoinQuestions
--
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
<http://www.catb.org/~esr/faqs/smart-questions.html>
moin-1.3-script_name.patch
(text/x-diff, 640 B)
--- /home/mss/tmp/moin-1.3/MoinMoin/request.py 2004-10-15 07:00:26.000000000 +0200
+++ request.py 2004-10-17 16:25:51.960096352 +0200
@@ -183,7 +183,7 @@
self.http_host = env.get('HTTP_HOST','localhost')
self.http_referer = env.get('HTTP_REFERER', '')
self.saved_cookie = env.get('HTTP_COOKIE', '')
- self.script_name = env.get('SCRIPT_NAME', '')
+ self.script_name = env.get('REDIRECT_SCRIPT_NAME', env.get('SCRIPT_NAME', ''))
self.path_info = env.get('PATH_INFO', '')
self.query_string = env.get('QUERY_STRING', '')
self.request_method = env.get('REQUEST_METHOD', None)