[pmwiki-users] Clean URLS cookbook question

Patrick R. Michaud pmichaud at pobox.com
Sun Feb 5 13:49:43 CST 2006


On Sat, Feb 04, 2006 at 11:12:36PM -0700, H. Fox wrote:
> On 2/4/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > The CleanUrls page currently has the information about $PubDirUrl
> > and $UploadUrlFmt in a separate section at the bottom of the page.
> 
> This was deliberate, not happenstance.  Explanation below...
> 
> > Since using CleanUrls nearly always requires setting these
> > variables,
> 
> They *used to* nearly always need to be set for clean URLs to work. 
> My refined instructions were, in part, intended to eliminate that
> necessity.  :-)

Unfortunately, it's not working for $UploadUrlFmt.

> $UploadUrlFmt is about the same.
> 
>   SDV($UploadUrlFmt,preg_replace('#/[^/]*$#',"/$UploadDir",$ScriptUrl,1));

The difference between $PubDirUrl and $UploadUrlFmt is that
$PubDirUrl is set *before* local customizations are performed
while $UploadUrlFmt is set *after* local customization are performed.

So, $PubDirUrl is set using the value of $ScriptUrl that is coming
from mod_rewrite (works), but $UploadUrlFmt is being set using the 
value of $ScriptUrl from config.php (doesn't work).

I've set up a couple of test cases on pmichaud.com using the CleanUrl
instructions for examples 1 and 2, you can see that uploads aren't
working.

    http://www.pmichaud.com/clean1/pmwiki
    http://www.pmichaud.com/clean2

> > AFAIK it's rare that $UploadDir has to be changed as a result of
> > CleanUrls, so I'd leave that one out entirely.
> 
> That variable is directly related to $UploadUrlFmt, so IMHO those two
> should be explained together.

While it's true that $UploadUrlFmt often depends on the setting of
$UploadDir, the reverse isn't true.  With the exception of sites
installed on sourceforge.net, I think it's quite rare that admins 
will be customizing $UploadDir -- usually that remains "uploads/
in the current directory".  Instead, $UploadUrlFmt tends to be
much more tightly integrated to changes with $ScriptUrl.

Another possibility to resolve this is for me to move the
$UploadUrlFmt initialization code out of scripts/upload.php
and into pmwiki.php, just so it's processed the same as
$PubDirUrl.  But somehow that feels "wrong" to me.

> To that end, I think it would be *much* easier to get uploads running
> if $UploadDir and $UploadUrlFmt  were documented in sample-config.php.

My only (admittedly minor) concern is that many people, even
experts, tend to confuse urls and directories.  Listing these
together might exacerbate that confusion.  Since $UploadDir
rarely needs to be changed, I'm thinking it might be better
left unmentioned.

Still, the version you propose makes sense to me, so I could
see about including it.

>   ##  $UploadDirFmt is the filesystem path and $UploadUrlFmt is the URL
>   ##  where a browser would look for the same directory.
>   # $UploadDir = '/filesystem/path/to/uploads';
>   # $UploadUrlFmt = 'http://www.mydomain.com/path/to/uploads';

Pm




More information about the pmwiki-users mailing list