[pmwiki-users] Removing the "pmwiki" part in the uploads URL when pmwiki resides in a subdirectory of the document root
Eemeli Aro
eemeli at gmail.com
Wed Mar 25 08:10:12 CDT 2009
Not quite your situation, but thought I'd mention my system, in case
it's of use to someone: I've got this type of pretty attachment URLs
working with direct downloads disabled and PmWiki completely outside
the web path. This requires a slightly non-intuitive setup.
First, I have the following in my Apache config:
RewriteRule ^attach/(.+)/([^/]+)$
index.php?n=$1&action=download&upname=$2 [QSA,L]
index.php contains the following single line:
<?php chdir('/path/to/wiki/dir/in/wikifarm');
include_once('/path/to/pmwiki.php');
I have multiple wikis on a single wikifarm, with a separate directory
for each wiki. The $UploadDir is left to the default, which gives me a
separate uploads directory inside each wiki directory. The common
pmwiki.php, cookbooks etc. are in a separate directory. These are all
of course outside the directory path accessible via the web; hence the
index.php mentioned above.
Now, for a final step I have this in my configuration:
$EnableDirectDownload = 1;
$UploadUrlFmt = '$ScriptUrl/attach';
And hence my attachments have URLs such as
http://example.com/attach/Main/image.png but the PmWiki authentication
is still used to control access. This works since even with direct
download supposedly enabled the requests are still passed through
pmwiki.php, and actual direct access is not possible.
I've also customised HandleDownload() to check the actual
last-modified timestamps for attachments such that I can return 304
messages as often as possible. Here's the code, added after line 172
of upload.php:
header("Cache-Control: ");
header("Expires: ");
$filelastmod = gmdate( 'D, d M Y H:i:s \G\M\T', filemtime($filepath) );
if ( @$_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filelastmod )
{ header("HTTP/1.0 304 Not Modified"); exit(); }
header("Last-Modified: $filelastmod");
eemeli
2009/3/17 Jo Vermeulen <jo.vermeulen at gmail.com>:
> Hi,
> I have set up clean URLs with Apache rewrite rules as ".htaccess in the
> Site's Document Root", which worked perfectly. The pmwiki installation
> resides in a pmwiki subdirectory, but the URL is
> http://example.com/Main/Homepage.
> However, the URL of uploaded files is still
> http://example.com/pmwiki/uploads/bla.png. Is there any recommended way of
> removing the "pmwiki" part in the uploads URL (maybe with another rewrite
> rule)?
> Thanks!
> -- Jo
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>
>
More information about the pmwiki-users
mailing list