Manual talk:$wgActionPaths
From MediaWiki.org
Contents |
[edit] "action" Directory
I created an "action" directory with an '.htaccess' and an 'index.php'.
# .htaccess RewriteEngine on RewriteRule ^(.*?)/(.*?)$ ../index.php?action=$1&title=$2
<?php # index.php header('Location: ../'); exit; ?>
From the visitor's side, it's identical. I did this because it would not work in conjunction with my other RewriteRules. Egingell 07:20, 16 August 2007 (UTC)
[edit] Alternate Option
On my setup, it would appear that using a '.htaccess' in the wiki root and using:
RewriteRule ^/action/([a-z]*)/(.*)$ /index.php?action=$1&title=$2 [L,QSA]
doesn't work as suggested. Using 'RewriteLog', I found that the following works:
RewriteRule ^action/([a-z]*)/(.*)$ index.php?action=$1&title=$2 [L,QSA]
Hope this helps somebody. Jean-Lou Dupont 01:17, 9 May 2007 (UTC)
Helped me! I had the same problem. You are a legend. Thank you Jldupont! -- 04:56, 12 May 2007 58.10.167.198
Neither works for me, presumably because of my other rewriting. =/ Sy Ali 00:34, 19 May 2007 (UTC)
[edit] Infinite Loop
Using RewriteRule ^/action/([a-z]*)/(.*)$ /index.php?action=$1&title=$2 [L,QSA]
on my .htaccess on (1)(2)(3) and (4) i get an infinite loop :|
RewriteEngine On
(1)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
(2)
RewriteRule ^wiki/(.*) wiki/index.php?title=$1 [PT,L,QSA]
(3)
RewriteRule ^wiki/*$ wiki/ [L,QSA]
RewriteRule ^/*$ wiki/ [L,QSA]
(4)
any ideas? LuisManson
-
- I don't know.
- The rule matches everything including 'index.php' (add
RewriteRule !^wiki/index.php$ - [C]just before it). - Same story as number 2.
- If
RewriteRule ^/*$ wiki/ [L,QSA]is number 4, it's still the same problem as numbers 2 and 3.
- Egingell 07:20, 16 August 2007 (UTC)
[edit] lighttpd and url rewriting
in your vhost conf or something:
url.rewrite-once = ( "^/wiki/$" => "/w/index.php", "^/wiki/a/([a-z]*)/(.*)$" => "/w/index.php?title=$2&action=$1" ) url.redirect = ( "^/(?!w|!^wiki/index.php$|wiki|robots\.txt|favicon\.ico)(.*)" => "/wiki/a/$1" )
in LocalSettings.php or wherever:
$wikiRoot = "/wiki"; $wgScript = "{$wgScriptPath}/index.php"; $actions = array('view', 'edit', 'watch', 'unwatch', 'delete', 'revert', 'rollback', 'protect', 'unprotect','info','markpatrolled','validate', 'render','deletetrackback','print', 'dublincore','creativecommons','credits', 'submit','viewsource','history','purge' ); foreach ($actions as $a) { $wgActionPaths[$a] = "{$wikiRoot}/action/$a/$1"; } $wgArticlePath = "{$wikiRoot}/action/view/$1";
BTW, I don't know if you noticed - I hope you did ;) - that in the lighttpd part, I flipped the rewritten substitutions (I think that's what they're called): "^/wiki/a/([a-z]*)/(.*)$" => "/w/index.php?title=$2&action=$1" -- see the $2 , then $1 ? I did that, otherwise it wouldn't work. I imagine I would have to compensate for older MW installs, that had the action=FOO&title=BAR instead of title=BAR&action=FOO like it is now. Seems to me lighttpd and MW are taking the query string very literally (which is of course a big fat "duh!").
(I didn't use the syntax highlighting, I don't remember the, um, syntax.)
-- Kjikaqawej 08:47, 6 September 2008 (UTC)
[edit] ...as for apache
I suppose you could very easily do this for an apache-based mediawiki, since I pretty much ripped the rewrites from that ;).
-- Kjikaqawej 08:49, 6 September 2008 (UTC)