[pmwiki-users] Clean URLS cookbook question

H. Fox haganfox at users.sourceforge.net
Sun Feb 5 00:12:36 CST 2006


On 2/4/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Sat, Feb 04, 2006 at 12:47:27PM -0700, H. Fox wrote:
> > On 2/3/06, H. Fox <haganfox at users.sourceforge.net> wrote:
> > > I'm interested to see what those cases are.  Mainly I was going for "a
> > > method that works reliably" as a baseline.
> >
> > I added an introduction to the to the examples.  The reason is to
> > clarify the cases that *are* covered (where the rewritten "root URL"
> > is in the same directory, the directory above, and the document root).
> >
> > http://www.pmwiki.org/wiki/Cookbook/CleanUrls#examples
>
> It's looking very good.
>
> 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.  :-)

> I think they need to go in the local/config.php
> examples above (even if it's repetitious), otherwise they'll
> get overlooked.

AFAICT $PubDirUrl doesn't need to be set if the instructions are
followed as written...  In pmwiki.php:

  $PubDirUrl = preg_replace('#/[^/]*$#','/pub',$ScriptUrl,1);

$UploadUrlFmt is about the same.

  SDV($UploadUrlFmt,preg_replace('#/[^/]*$#',"/$UploadDir",$ScriptUrl,1));

If they really do need to be set we should add them to the examples. 
If not, they definitely should *not* be there.  I assumed the latter
for two reasons:
1) I did much testing, and
2) I discovered the lines of code above.

Put another way:  I omitted them due to the "MiNoNeBe" principal (More
is Not Necessarily Better :-) ).  For completeness, I put them in a
note.

> 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.

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

  ##  It may be necessary to set the location of the uploads/ directory.
  ##  $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';

> Lastly, there are a couple of approaches for doing clean urls
> that don't require mod_rewrite, and we ought to document those
> somewhere -- probably on separate pages.

Separate pages would probably be better for those.  Do the vast
majority of Apache servers support mod_rewrite?

>  Any idea how we should
> connect those to the existing page?  I'm thinking that CleanUrls
> should indicate somewhere early in the page that Apache's mod_rewrite
> is the most popular approach to clean urls, but for sites that aren't
> running Apache or that don't have access to mod_rewrite, there
> are some other alternatives available.
>
> The other two useful approaches are (1) add Alias entries in
> httpd.conf,

I had a note about that.  Now it includes two examples.

> and (2) create a PHP script that doesn't have the ".php"
> extension in it but is able to call PmWiki.

I'll let you do that one if you want.  My gut feeling is that it will
confuse people more than it will help them.

For now I added a note about shortening URLs using an index.php file,
as in turning
  http://www.example.com/~someuser/pmwiki/pmwiki.php?n=Main.HomePage
into
  http://www.example.com/~someuser/pmwiki/?n=Main.HomePage
or
  http://www.example.com/~someuser/?n=Main.HomePage

" Using an Index File (index.php) To Shorten URLs"
http://www.pmwiki.org/wiki/Cookbook/CleanUrls#index_php_note

It's shorter than a PHP script that doesn't have the ".php" extension
-- and it doesn't display a ".php" extension.  :-)

> Perhaps CleanUrls should itself be an overview page, with a
> description of the approaches and links to CleanUrlsRewrite,
> CleanUrlsAlias, and CleanUrlsScript, or something like that.

I'm leaning toward this instead:
> Or, we can leave CleanUrls as being focused on mod_rewrite
> (since it's the most popular approach), but if we do that there
> should be easy-to-find links to the other approaches (even if
> they're just placeholder links until those documents are written).

That sounds reasonable.  I wrote some possible content for those
pages, but Cookbook.CleanUrls is still a monolithic page at this
point.

Hagan




More information about the pmwiki-users mailing list