[pmwiki-users] I need help with clean URLs

Patrick R. Michaud pmichaud at pobox.com
Sat Aug 12 16:22:49 CDT 2006


On Sat, Aug 12, 2006 at 01:23:00PM -0700, info at theburroughsproject.com wrote:
> Patrick, thank you very much for clearing all that up. Unfortunately,
> this still isn't working for me. This is what I've done:
> 
> I created an "index.php" file, that contains the single line:
> <?php include_once('pmwiki.php');
> 
> This works fine for making "www.example.com" work. 

Excellent!

> Then I created an .htaccess file with exactly this in it:
> 
> # Use mod_rewrite to enable "Clean URLs" for a PmWiki installation.
> RewriteEngine On
> # The rewrite base will be the document root.
> RewriteBase /
> # Send requests without parameters to pmwiki.php.
> RewriteRule ^$           pmwiki.php  [L]
> # Send requests for index.php to pmwiki.php.
> RewriteRule ^index\.php$ pmwiki.php  [L]
> # Send requests to pmwiki.php, appending the query string part.
> RewriteRule ^([^/a-z].*) pmwiki.php?n=$1  [QSA,L]
> 
> and placed it in my main web folder (the same one that contains
> "pmwiki.php").
> 
> At this point URLs like "www.example.com/SomeGroup/SomePage" do not
> work, I just get a 404, but the old URLs, with the
> "?n=SomeGroup.SomePage" still work fine.

Hmm.  I've done some reading on this, and apparently some GoDaddy
accounts don't support htaccess, or at least not "out of the box".

First, I note that all of GoDaddy's documentation refers to
"htaccess" without the dot, so you might try renaming ".htaccess"
to "htaccess" and see if that fixes anything.

If that doesn't work, it may be that you need to "upgrade your account 
to run Hosting Configuration 2.0", whatever that means.  GoDaddy describes
this somewhat at 
http://help.godaddy.com/article.php?article_id=1082&prog_id=GoDaddy .

> I went ahead and tried the next step, to see what would happen, adding:
> 
> <?php if (!defined('PmWiki')) exit();
> $EnablePathInfo = 1;
> $ScriptUrl = 'http://www.example.com';
> ## remainder of configuration goes here
> 
> to my config file, and now the links point to clean URLs, but I still
> get the 404 when I click them (the old URLs still work, though).

Yes, until we get the rewrite rules working the clean urls won't work.

> Or is it possible that I need to create a php.ini file with something in
> it? I know my hosting service will allow this, and I seem to remember
> that coming up in another post in the archive...

It's not affected by the php settings at all -- at this point it's
all trying to get Apache to do the right thing.  And, just to make
sure, you are running a GoDaddy account that is using Apache as
the webserver, yes?  (Is it a Linux account or a Windows account?)

Hope this helps,

Pm


> On Fri, Aug 11, 2006 at 11:57:29PM -0700, info at theburroughsproject.com
> wrote:
> > Hello. I'm having a very difficult time getting clean URLs. I have my
> > pmwiki.php file and all of the folders in my main directory. 
> > 
> > Right now my URLs look like this:
> > www.example.com/pmwiki.php?n=SomeGroup.SomePage
> > 
> > I want my URLs to look like this:
> > www.example.com/SomeGroup/SomePage
> > 
> > And I'd like, if possible, for the Main.HomePage URL to just be:
> > www.example.com/
> 
> This looks like "Example Three" from the Cookbook.CleanUrls
> page, so you'll want to follow it.
> 
> First, let's get www.example.com/ to work for your Main.HomePage.
> Create a file called 'index.php' in the same directory as pmwiki.php,
> in that file place the line:
> 
>    <?php include_once('pmwiki.php');
> 
> After doing this, then the url http://www.example.com/ should
> automatically display the Main.HomePage.
> 
> Okay, now for the rest of the clean urls.  Create a file called
> '.htaccess' in the same directory as pmwiki.php, and in that
> file include the following lines:
> 
>    # Use mod_rewrite to enable "Clean URLs" for a PmWiki installation.
>    RewriteEngine On
>    # The rewrite base will be the document root.
>    RewriteBase /
>    # Send requests without parameters to pmwiki.php.
>    RewriteRule ^$           pmwiki.php  [L]
>    # Send requests for index.php to pmwiki.php.
>    RewriteRule ^index\.php$ pmwiki.php  [L]
>    # Send requests to pmwiki.php, appending the query string part.
>    RewriteRule ^([^/a-z].*) pmwiki.php?n=$1  [QSA,L]
> 
> After making this change, urls that look like
> www.example.com/SomeGroup/SomePage should work.
> 
> Lastly, we need to configure PmWiki to use the new "clean" urls
> instead of its default, thus in local/config.php, place the lines
> 
>    <?php if (!defined('PmWiki')) exit();
>    $EnablePathInfo = 1;
>    $ScriptUrl = 'http://www.example.com';
>    ## remainder of configuration goes here
> 
> This will tell PmWiki to generate its links using the
> www.example.com/SomeGroup/SomePage format instead of
> www.example.com/pmwiki.php?n=SomeGroup.SomePage .
> 
> > For example, whenever it mentions "~someuser", is that the same as
> > saying "somefolder"? Or is there a significance with the "~" and the
> > term "user"? What's a "user" in this context?
> 
> Aha, you've found a hole of sorts in the CleanUrls description.
> CleanUrls was written from the perspective of someone having
> installed PmWiki into a per-user directory on a server, where
> urls all tend to begin with the user's name.  But your situation
> is running PmWiki from the document root directory, or from
> a place that isn't associated with the server's user accounts.
> In fact, I'd tend to think that your situation is the more common
> one.
> 
> So, perhaps what we need to do is to eliminate the "~someuser"
> references and just use "path/to/pmwiki" instead, so that
> the administrator understands to simply replace that component
> of the path (without any reference to "~someuser").
> 
> Any comments from the group?
> 
> > And where it says:
> > 
> > >   Here's the matching local/config.php file: 
> > >
> > >   <?php if (!defined('PmWiki')) exit();
> > >   ## Use "Clean URLs".
> > >   $EnablePathInfo = 1;
> > >   $ScriptUrl = "http://server.example.com/~someuser/pmwiki";
> > >   ## more configuration settings...
> > 
> > what does the "server" in "server.example.com/~someuser/pmwiki";"
> > supposed to be? Am I supposed to change that to something? 
> 
> That's a typo in the recipe, it should match all of the other
> server references --- i.e., it should also be "www.example.com".
> 
> > If someone could dumb this down for me, just give me a more "plain
> > language" step-by-step that's not way over my head, I'd really
> > appreciate it a lot. I've been trying different things for quite some
> > time, and I just can't make it work. I don't know much about servers or
> > rewriting.
> 
> I hope the above is helpful -- if not, please keep asking.
> Your questions have already pointed out some important gaps
> in the current documentation, so this is a huge help to us all.
> 
> Thanks!
> 
> Pm 
> 
> 




More information about the pmwiki-users mailing list