最近更新 - 使用說明 - 測試區 - 搜尋:
●獅吼文集
楔子?
佛法入門?
三藏經典?
修持正見?
法義討論?
實修儀軌?
名相淺釋?
佛教X檔案?
學佛心得?
佛教人物?
●其它
暫存區?
工作討論?
編輯選單

連結!pmwiki.org
* Cookbook
* Development
* PmWikiUsers
* SuccessStories

編輯本頁 列印預覽 群組歷史 本頁歷史


PmWiki is designed to be usable as a web site maintenance tool, and frequently administrators will want to be able to provide access to PmWiki pages without having "pmwiki.php" appear in the address bar of the users' browser windows. This page describes ways to have your PmWiki installation appear as a URL other than that of the pmwiki.php script itself. The examples below assume that a URL such as http://www.example.com/wiki is being set to refer to pmwiki.php on the www.example.com website.

There are four basic ways to accomplish this: aliasing, making a "wiki" script, renaming the pmwiki script, or using mod_rewrite.

Aliasing

First, if you have access to the web server configuration file, then simply adding the line

        Alias /wiki /path/to/pmwiki.php

to the configuration file will perform the alias for you. In some cases (for instance Apache 2.0) you might be forced to use the full path to pmwiki.php, i.e.

        Alias /wiki /home/account/www/pmwiki.php

even when you've already defined the documentroot as /home/account/www. You'll then need to set $PubDirUrl and $UploadsUrlFmt variables in config.php to point to the correct urls for your pub/ and uploads/ directories.

Added by heck@fas.harvard.edu: Using Apache 2.0.x, I also needed to alias the pub directory. The link tags that load the style sheets will now point at e.g. http://example.com/wiki/pub/css/stdlayout.css, but that is aliased to /home/account/www/pmwiki.php/pub/css/stdlayout.css, which makes no sense. The solution is to add another alias:

        Alias /wiki/pub /home/account/www/pub

Note that you can put these directories anywhere: They do not have to be under your DocumentRoot.

NOTE (added be tj-AT-web62.com): Tis did not work for me, dont know why. If I did it like above, the second Alias just triggered a request to the wiki error message

'pub/skins/pmwiki/pmwiki.css' is not a valid PmWiki page name

I had to add an

Alias /pub /home/account/www/pub

to get it work right!

It seems that all steps described below only make sense, if in the configuration file of the webserver "AllowOverride None" not is set. All user specific directives are forbidden this way. So what then?? (fhattop@yahoo.de)

Making a "wiki" script

If you don't have access to the configuration file, then a little bit of redirection is needed. First, create a file (not a directory) called "wiki" at the location where the webserver would normally access the "/wiki" URL. Often this is the web server's DocumentRoot directory, but it really depends on your site's configuration. Place the following PHP script in the wiki file:

    <?php chdir("/path/to/pmwikidir"); include("pmwiki.php"); ?>

In the script, replace /path/to/pmwikidir with the name of the directory containing pmwiki.php. Then, add the following lines to the .htaccess file in the same directory as the wiki file (create the .htaccess file if doesn't exist):
    
    <Files wiki>
    SetHandler application/x-httpd-php
    </Files>

This tells the webserver to treat the wiki file as a PHP script even though it doesn't end in .php. Now, requests for your wiki file will cause the web server to change to the directory containing pmwiki.php and execute it from there. Make sure $ScriptUrl in config.php is pointing at the wiki file, and not at the directory containing pmwiki.php.

Renaming the pmwiki.php file

A third method is to just rename "pmwiki.php" to a more suitable name, for instance "do.php". If you're going to use the webalizer web log analysis, you shouldn't rename "pmwiki.php" to "index.php". Webalizer 'strips' urls after the 'index.' part, thus effectively destroying all page referrals. For instance: access to '/index.php/Main/Abc' and '/index.php/Main/Xyz' are both referred to as '/', with two counts.

If you want pmwiki to load automatically when you type in a URL that ends in a directory, you can do one of two things. If you can use the Alias directive in your web server configuration file, simply use the Alias directive described above. If you cannot do so, try adding the following to the .htaccess file in the pmwiki directory:

  DirectoryIndex pmwiki.php

This causes pmwiki.php to be loaded by default instead of index.php or index.html, and obscures the filename, at least for first-time visitors.

Using mod_rewrite

The Apache Web server has all kinds of crazy features, one of which is mod_rewrite. The following recipe in an .htaccess file should get your urls looking real real nice:
    
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([A-Z].*) /path/to/pmwiki/pmwiki.php?pagename=$1 [L,qsappend]

When using mod_rewrite make sure you have all the following set in your local/config.php

   $ScriptUrl = 'http://yourdomain.com/dir/pmwiki.php';
   $PageUrlFmt = 'http://yourdomain.com/$Group/$Title_';
   $PubDirUrl = 'http://yourdomain.com/dir/pub';
   $UploadUrlFmt = 'http://yourdomain.com/dir/uploads';

Getting cleaner URLs out of PmWiki

You have to change your local configuration to get PmWiki itself to generate pretty urls. Setting the $EnablePathInfo variable to 1 will tell PmWiki to make pretty page names with slashes ("/") instead of dots in them, and no "pagename=" stuff. Then, setting $ScriptUrl to the pseudo-path you set up, without a trailing slash, will make things look really nice. For instance, the above mod_rewrite commands combined with
  $ScriptUrl = "http://wiki.example.com";
in config.php would result a URL that looks like this
  http://wiki.example.com/Main/HomePage/.



<< MailPosts | PmWiki.DocumentationIndex | CustomInterMaps >>
編輯本頁 - 列印預覽 - 群組歷史 - 本頁歷史 - 搜尋
本頁更新於 2004 年 04 月 19 日,06:28 AM