rewrite
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rewrite [2023-08-24 20:18] – Corrected download links for ReWrite Modules for IIS 20.228.205.132 | rewrite [2024-03-13 11:51] (current) – link to up2date apache2 doc 185.177.84.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
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 |
- | The solution is to enable URL rewriting, which is disabled by default. | + | ===== Rewriting options |
- | + | ||
- | ===== Instructions in plain English ===== | + | |
- | + | ||
- | ==== Steps ==== | + | |
- | + | ||
- | - Go to Admin | + | |
- | - Open Configuration Settings | + | |
- | - Change Nice URLs option to .htaccess (use find, it's far down) | + | |
- | - Underneath it, check the option to "Use slash as namespace separator in URLs" | + | |
- | - Save | + | |
- | - Next, using an ftp or file manager, you need access to your /wiki/ folder that you created when creating your wiki. | + | |
- | - Inside, you'll find a file called .htaccess and .htaccess.dist. (if you don't see it, make sure you have hidden files visible. It may be an option you have while logging on depending on your hosting provider, or, simply create a file called .htaccess and upload it) | + | |
- | - inside the .htaccess file, paste the following (alternatively uncomment section in .htaccess.dist then rename to .htaccess): | + | |
- | + | ||
- | <code apache> | + | |
- | RewriteEngine on | + | |
- | + | ||
- | RewriteRule ^_media/ | + | |
- | RewriteRule ^_detail/ | + | |
- | RewriteRule ^_export/ | + | |
- | RewriteRule ^$ doku.php | + | |
- | RewriteCond %{REQUEST_FILENAME} | + | |
- | RewriteCond %{REQUEST_FILENAME} | + | |
- | RewriteRule (.*) doku.php? | + | |
- | RewriteRule ^index.php$ | + | |
- | </ | + | |
- | + | ||
- | This will give you a format like www.myexample.com/ | + | |
- | + | ||
- | <code apache> | + | |
- | RewriteBase /dokuwiki | + | |
- | </ | + | |
- | + | ||
- | where /dokuwiki should be changed to the actual name of the folder you are using. | + | |
- | + | ||
- | + | ||
- | ===== Further Details for the Technically Savvy ===== | + | |
DokuWiki supports two methods for URL rewriting, enabled through the [[config: | DokuWiki supports two methods for URL rewriting, enabled through the [[config: | ||
Line 55: | 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. | ||
+ | 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. | ||
- | ==== Apache | + | * [[install:Apache]] -- uses the [[http:// |
+ | * [[install: | ||
+ | * [[install: | ||
+ | * [[install: | ||
- | Rewriting URLs in Apache is done through the **mod_rewrite** module of [[http:// | ||
- | DokuWiki comes with an '' | + | Once the rewriting support has been enabled in the web server, this option can be enabled in the DokuWiki configuration. |
- | Here is an example | + | Select the '' |
- | <code apache> | + | |
- | RewriteEngine on | + | |
- | RewriteBase /dokuwiki | + | < |
- | + | $conf[' | |
- | RewriteRule ^_media/ | + | |
- | RewriteRule ^_detail/ | + | |
- | 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 affect //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} !^/ | + | $conf[' |
</ | </ | ||
- | or creating an empty server-status file in dokuwiki root folder where doku.php is located. See forum post [[http:// | ||
- | == 404 not found error == | ||
- | You may need to do [[https:// | ||
- | ==== IIS (or Microsoft Azure Web App) ==== | ||
- | Enable url rewriting and insert appropriate set of rules: | ||
- | |||
- | <code xml> | ||
- | < | ||
- | < | ||
- | |||
- | <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=" | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | **If you are using Azure Web App**, just put these lines under the < | ||
- | |||
- | |||
- | === 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 [[https:// | ||
- | |||
- | 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:// | ||
- | |||
- | <code nginx> | ||
- | 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 proper linking in dokuwiki. This can be done | ||
- | in the server section with: | ||
- | |||
- | <code nginx> | ||
- | fastcgi_param HTTPS on; | ||
- | </ | ||
- | |||
- | The '' | ||
- | |||
- | 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. | ||
- | |||
- | ==== httpd (OpenBSD) ==== | ||
- | See also [[https:// | ||
- | |||
- | <code autoconf> | ||
- | server " | ||
- | listen on egress port 443 | ||
- | root "/ | ||
- | directory index doku.php | ||
- | | ||
- | # Set according to upload_max_filesize and post_max_size in php.ini | ||
- | connection max request body 20971520 | ||
- | |||
- | location " | ||
- | | ||
- | # Block access to non-public dirs | ||
- | location "/ | ||
- | location "/ | ||
- | location "/ | ||
- | location "/ | ||
- | location "/ | ||
- | | ||
- | # URL rewrite rules | ||
- | location match "/ | ||
- | request rewrite "/ | ||
- | } | ||
- | | ||
- | location match "/ | ||
- | request rewrite "/ | ||
- | } | ||
- | | ||
- | location match "/ | ||
- | request rewrite "/ | ||
- | } | ||
- | |||
- | location match "/ | ||
- | request rewrite "/ | ||
- | } | ||
- | |||
- | location match "/ | ||
- | request rewrite "/ | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | ====== Option 2: DokuWiki ====== | ||
- | |||
- | In your conf/ | ||
- | |||
- | <code php> | ||
- | $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 289: | Line 74: | ||
</ | </ | ||
- | ====== Also see ====== | + | ====== |
* [[: | * [[: | ||
* [[https:// | * [[https:// | ||
+ |
rewrite.1692901120.txt.gz · Last modified: 2023-08-24 20:18 by 20.228.205.132 · Currently locked by: 111.41.208.155