rewrite
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rewrite [2015-05-07 22:48] – [Apache] 75.148.84.233 | rewrite [2024-03-13 11:51] (current) – link to up2date apache2 doc 185.177.84.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== URL Rewriting ====== | ====== URL Rewriting ====== | ||
- | |||
- | FIXME This page is a mess and should be rewritten. | ||
By default, DokuWiki does no URL rewriting, resulting in URLs like this: | By default, DokuWiki does no URL rewriting, resulting in URLs like this: | ||
- | http:// | + | http:// |
| | ||
- | These URLs are considered | + | These URLs are somewhat |
+ | |||
+ | ===== Rewriting options ===== | ||
- | The solution is to enable URL rewriting, which is disabled by default. | + | DokuWiki supports two methods for URL rewriting, enabled through the [[config: |
^ Value ^ Info ^ Example URL ^ | ^ Value ^ Info ^ Example URL ^ | ||
Line 18: | Line 18: | ||
URL-Rewriting is disabled by default because it requires some additional configuration besides setting the appropriate [[config: | URL-Rewriting is disabled by default because it requires some additional configuration besides setting the appropriate [[config: | ||
- | URL-Rewriting can be enabled at ''? | + | ==== Option |
- | ====== Option 1: web server ====== | ||
- | :!: Remember to set following in the Configuration Manager ''/ | ||
- | * Use nice URLs: **.htaccess** | ||
- | * Use slash as namespace separator in URLs [**x**] | ||
- | Otherwise rewrite rules will not be useful. | ||
- | ==== Apache ==== | + | This option requires some setup in the webserver first. How to enable it, depends on the webserver used. Please refer to the linked pages below for additional info. |
- | Rewriting URLs in Apache | + | * [[install:Apache]] -- uses the [[http:// |
+ | * [[install: | ||
+ | * [[install:nginx]] -- has built in rewriting support | ||
+ | * [[install: | ||
- | DokuWiki comes with an '' | ||
- | Here is an example | + | Once the rewriting support has been enabled in the web server, this option can be enabled in the DokuWiki configuration. |
- | <code apache> | + | |
- | RewriteEngine on | + | |
- | RewriteBase | + | Select the '' |
- | RewriteRule ^_media/ | + | < |
- | RewriteRule ^_detail/ | + | $conf[' |
- | RewriteRule ^_export/ | + | |
- | RewriteRule ^$ doku.php | + | |
- | RewriteCond %{REQUEST_FILENAME} | + | |
- | RewriteCond %{REQUEST_FILENAME} | + | |
- | RewriteRule (.*) doku.php? | + | |
- | RewriteRule ^index.php$ | + | |
</ | </ | ||
- | On the line '' | + | In DokuWiki root folder, find the file '' |
+ | ==== Option 2: DokuWiki ==== | ||
- | You may also need to rename the file from '' | ||
- | == Apachectl status broken == | + | This option won't need any webserver setup. However it relies on the PATH_INFO feature of the CGI standard as implemented by Apache. Some webserver configurations might not support it. |
- | Dokuwiki rewrite rule effect //apachectl status// command and make it return dokuwiki 404 page instead of the server-status page. You can fix that by either putting this in dokuwiki rewrite rules | + | To enable this option, select |
- | + | ||
- | RewriteCond %{REQUEST_URI} !^/ | + | |
- | + | ||
- | or creating an empty server-status file in dokuwiki root folder where doku.php is located. see forum post [[http:// | + | |
- | + | ||
- | ==== IIS ==== | + | |
- | Enable url rewriting and insert appropriate set of rules: | + | |
- | + | ||
- | <code iis> | + | |
- | < | + | |
- | < | + | |
- | + | ||
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | </ | + | |
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | </ | + | |
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | </ | + | |
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | < | + | |
- | <add input=" | + | |
- | <add input=" | + | |
- | </ | + | |
- | </ | + | |
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | < | + | |
- | <add input=" | + | |
- | <add input=" | + | |
- | </ | + | |
- | </ | + | |
- | <rule name=" | + | |
- | <match url=" | + | |
- | <action type=" | + | |
- | </ | + | |
- | </ | + | |
- | </ | + | |
+ | <code php> | ||
+ | $conf[' | ||
</ | </ | ||
- | > Where should I put that rules?! | ||
- | === IIS 7.0 or greater === | ||
- | IIS 7.0 and above can be extended with a the URL Rewrite module 2.0 available from Microsoft for both [[http:// | ||
- | |||
- | Save the Apache rules above to a .htaccess file removing the " | ||
- | |||
- | In IIS Manager select your Wiki folder, and under IIS select "URL Rewrite" | ||
- | |||
- | In the actions pane on the right hand side, choose " | ||
- | |||
- | For your configuration file, select the .htaccess file and Import, this should give you 6 converted rules. | ||
- | |||
- | Finally hit Apply in the Actions panel on the right hand side. | ||
- | |||
- | Configure your Wiki to use .htaccess rules for rewrite and you should now be seeing your URLs rewritten. | ||
- | |||
- | ==== Nginx ==== | ||
- | |||
- | See [[http:// | ||
- | |||
- | < | ||
- | server { | ||
- | listen 80; | ||
- | server_name example.com www.example.com; | ||
- | |||
- | #maximum file upload size is 4MB - change accordingly if needed | ||
- | client_max_body_size 4M; | ||
- | client_body_buffer_size 128k; | ||
- | |||
- | root / | ||
- | index doku.php; | ||
- | |||
- | location / { try_files $uri $uri/ @dokuwiki; } | ||
- | |||
- | location @dokuwiki { | ||
- | rewrite ^/ | ||
- | rewrite ^/ | ||
- | rewrite ^/ | ||
- | rewrite ^/ | ||
- | } | ||
- | |||
- | location ~ \.php$ { | ||
- | if (!-f $request_filename) { return 404; } | ||
- | include fastcgi_params; | ||
- | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
- | fastcgi_param REDIRECT_STATUS 200; | ||
- | fastcgi_pass 127.0.0.1: | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | === Notes === | ||
- | |||
- | If using https the HTTPS server variable has to be set to allow propper linking in dokuwiki. This can be done | ||
- | in the server section with: | ||
- | |||
- | fastcgi_param HTTPS on; | ||
- | |||
- | 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. | ||
- | |||
- | If you are copy-pasting these configs, make sure you are adding locations to secure some of the directories as described on [[security|Security]] page. | ||
- | |||
- | ====== Option 2: DokuWiki ====== | ||
- | |||
- | In your conf/ | ||
- | |||
- | | $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> | ||
===== Clean PHP session ID ===== | ===== Clean PHP session ID ===== | ||
Line 198: | Line 74: | ||
</ | </ | ||
- | ====== Also see ====== | + | ====== |
* [[: | * [[: | ||
+ | * [[https:// | ||
+ |
rewrite.1431031727.txt.gz · Last modified: 2015-05-07 22:48 by 75.148.84.233