差分
このページの2つのバージョン間の差分を表示します。
| dokuwiki:ja:rewrite [2006/11/11] – 作成 administrator | dokuwiki:ja:rewrite [2022/03/12] (現在) – 外部編集 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== URL Rewriting ====== | ||
| + | |||
| + | By default DokuWiki does no URL rewriting resulting in URLs like this: %%http:// | ||
| + | |||
| + | ^ Value ^ Info ^ Example URL ^ | ||
| + | | 0 | No URL rewriting is used. This is the default. | ||
| + | | 1 | Rewriting is handled by the webserver. | ||
| + | | 2 | Rewriting is done by DokuWiki. | ||
| + | |||
| + | URL-Rewriting is disabled by default because it needs some additional configuration besides setting the appropriate [[wiki: | ||
| + | |||
| + | ===== Option 1: Webserver ===== | ||
| + | |||
| + | | $conf[' | ||
| + | |||
| + | This option produces the nicer URLs but needs a webserver configured to parse rewritten URLs and give DokuWiki the deconstructed URL. | ||
| + | |||
| + | ==== Apache ==== | ||
| + | |||
| + | Rewriting URLs in Apache is done through the mod_rewrite module of [[http:// | ||
| + | |||
| + | DokuWiki comes with an .htaccess.dist file which contains the needed rewrite rules for mode 1, but commented. Just copy the file to .htaccess (in the folder that contains doku.php, caveat debian users) and uncomment the lines to enable rewriting. | ||
| + | |||
| + | < | ||
| + | RewriteEngine on | ||
| + | |||
| + | RewriteBase /dokuwiki | ||
| + | |||
| + | RewriteRule ^_media/ | ||
| + | RewriteRule ^_detail/ | ||
| + | RewriteRule ^_export/ | ||
| + | RewriteRule ^$ doku.php | ||
| + | RewriteCond %{REQUEST_FILENAME} | ||
| + | RewriteCond %{REQUEST_FILENAME} | ||
| + | RewriteRule (.*) doku.php? | ||
| + | RewriteRule ^index.php$ | ||
| + | </ | ||
| + | |||
| + | On the line '' | ||
| + | |||
| + | === Some Notes === | ||
| + | |||
| + | .htaccess files are only honored if Apache' | ||
| + | |||
| + | <code apache> | ||
| + | < | ||
| + | AllowOverride All | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Alternativly you may simply specify the rewrite rules mentioned above directly in the httpd.conf: | ||
| + | |||
| + | <code apache> | ||
| + | < | ||
| + | RewriteEngine on | ||
| + | ... rewrite rules here ... | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | You may have to restart Apache for these changes to work. | ||
| + | |||
| + | ==== IIS ==== | ||
| + | |||
| + | IIS doesn' | ||
| + | |||
| + | <code apache> | ||
| + | # Dokuwiki rules | ||
| + | |||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | |||
| + | RewriteRule (/wiki/) $1doku.php [I,L] | ||
| + | |||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | RewriteRule ^(/ | ||
| + | |||
| + | # this rule fixes a problem to see the old revisions | ||
| + | RewriteRule ^(/ | ||
| + | </ | ||
| + | |||
| + | For all lines with '' | ||
| + | |||
| + | ==== Lighttpd ==== | ||
| + | |||
| + | This is an improved version of one [[http:// | ||
| + | |||
| + | < | ||
| + | url.rewrite-once = ( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | ==== Nginx ==== | ||
| + | Nginx is a very fast and stable httpd, see more about [[http:// | ||
| + | < | ||
| + | server { | ||
| + | listen | ||
| + | server_name | ||
| + | port_in_redirect off; | ||
| + | optimize_server_names off; | ||
| + | |||
| + | access_log | ||
| + | |||
| + | rewrite ^(/ | ||
| + | rewrite ^(/ | ||
| + | rewrite ^(/ | ||
| + | |||
| + | location / { | ||
| + | root / | ||
| + | index index.html index.htm index.php; | ||
| + | } | ||
| + | |||
| + | location /dokuwiki/ { | ||
| + | if (!-f $request_filename) { | ||
| + | rewrite ^(/ | ||
| + | rewrite ^(/ | ||
| + | } | ||
| + | } | ||
| + | |||
| + | error_page | ||
| + | location = /50x.html { | ||
| + | root / | ||
| + | } | ||
| + | |||
| + | location ~ \.php$ { | ||
| + | fastcgi_pass | ||
| + | fastcgi_index | ||
| + | fastcgi_param | ||
| + | include | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | === Notes === | ||
| + | Nginx has complete support for fastcgi, please reference [[http:// | ||
| + | |||
| + | The last keyword of rewrite rules before location setup make sure that rewrite only happens once. You should replace all /dokuwiki/ appeared above to you wiki directory relative to web server root directory. | ||
| + | |||
| + | ===== Option 2: DokuWiki ===== | ||
| + | |||
| + | | $conf[' | ||
| + | |||
| + | This option won't need any webserver setup. However it relies on the PATH_INFO feature of the CGI standard as implemented by Apache. IIS is [[bug> | ||