[pmwiki-users] Clean URLs Revisited

Waylan Limberg waylan at gmail.com
Thu Oct 6 09:54:18 CDT 2005


On 10/6/05, Sivakatirswami <katir at hindu.org> wrote:
> OK we have
>
> 1) a farm installation of pmwiki here:
>
> /pmwiki/pmwiki.php
>
> 2) a field here
>
> /web_seva/wiki
>
> where the index.html file contains <?php include('../../pmwiki/
> pmwiki.php'); ?>
>
> everything works fine... now, trying to implement clear urls... in
> the field:
>
> /web_seva/wiki/local/config.php
>
> we set, as per cookbook guide:
>
> $ScriptUrl = 'http://www.himalayanacademy.com/web_seva/wiki/index.php';
> $EnablePathInfo = 1;
>
> Ok still, so far so good, no problems: but we are getting even
> without any .htaccess mod_rewrite directives:
>
> http://www.himalayanacademy.com/web_seva/wiki/index.php/HPI/
> HinduPressInternational
>
> now, how to eliminate the "index.php" in the URL string? OK, next
> try .htaccess mod_rewrite
>
> create file in the field directory, at the top:
>
> /web_seva/wiki/.htaccess:
>
> Options +FollowSymLinks
>    RewriteEngine on
>
>    # Redirect browsers that use an empty URL
>    # to the default URL.
>    RewriteRule ^/?$ http://www.himalayanacademy.com/web_seva/wiki/
> [R=permanent,QSA,L]
>
>    # Map URLs that start with anything but a lower-case letter to
> pmwiki.php.
>    # The remaining URLs are left to the default map-to-filesystem
> routine of Apache.
>    RewriteRule ^([^/a-z].*) index.php?n=$1 [QSA,L]
>
> An attempt to enter the home page generates an error from Apache:
> "Redirection limit for this URL exceeded. Unable to load the
> requested page. This may be caused by cookies that are
> blocked" (which they are not in my browser prefs)
>

I'm not 100% sure, but I think this is a result of not setting the
RewriteBase. Whenever you define rewrite rules in a .htaccess file
that is not at the server root you should define RewriteBase. This
basicly tells Apache to treat said directory as the root dir  for the
following rules. Before any rewrite rules, but after "RewriteEngine
on" add the line:

RewriteBase /local/path/to/web_seva/wiki/

> ??  But... if you enter a full URL:
>
> http://www.himalayanacademy.com/web_seva/wiki/index.php/HPI/
> HinduPressInternational
>
> it goes right thru just fine, but the "index.php" part of the string
> is not eliminated..
>

That's correct, and it should. Conversely, if you enter
http://www.himalayanacademy.com/web_seva/wiki/HPI/HinduPressInternational
that should work as well. Enabling the clean URLs does not redirect
URLs of the old format to the new. It just directs the URLs of the new
format to the old (transparently to the user).

However, if PmWiki is still generating the URLs in the old format then
that is another matter. Mod_Rewrite only tells Apache which URLs to
direct to PmWiki (or elsewhere), but otherwise has no effect on how
PmWiki acts. Therefore you need to make the following change in
config.php:

ScriptUrl = "http://www.himalayanacademy.com/web_seva/wiki";

Notice, we dropped the "/index.php" part of the URL.


--
----
Waylan Limberg
waylan at gmail.com




More information about the pmwiki-users mailing list