DokuWiki

It's better when it's simple

User Tools

Site Tools


rewrite

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rewrite [2014-04-29 15:37] 207.172.223.242rewrite [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://example.com/doku.php?id=page%%+  http://example.com/doku.php?id=wiki:syntax 
 +   
 +These URLs are somewhat ugly and might not be indexed well by some search engines. URL rewriting offers a solution to this, resulting in nicer URLs.
  
-These URLs are considered ugly and are not indexed well by some search engines. +===== Rewriting options =====
  
-The solution is to enable URL rewriting, which is disabled by default. DokuWiki supports two methods for URL rewriting through the [[config:userewrite]] option. One utilizes the rewriting capabilities of the webserver; the other one handles rewritten URLs inside DokuWiki. The table below summarizes these options.+DokuWiki supports two methods for URL rewriting, enabled through the [[config:userewrite]] option. One relies on the rewriting capabilities of the webserver; the other one handles rewritten URLs inside DokuWiki. The table below summarizes these options.
  
 ^ 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:userewrite|config option]] - these configs are discussed below. URL-Rewriting is disabled by default because it requires some additional configuration besides setting the appropriate [[config:userewrite|config option]] - these configs are discussed below.
  
-**Nota Bene** In all the following examples, add or modify the line in your conf/local.php file so it reads:+==== Option 1web server ====
  
-| $conf['userewrite'] = N; | 
  
-where N is the number 1 or 2.  (No need to do anything if you want the option 0.) 
  
-===== Option 0: editing php code and filenames =====+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.
  
-This is not about URL rewrite but when you need to replace the "doku.php" for local reasons (it doesn't sound so well in all languages)I performed it with Apache server but I think it is similar or even the same with others+  * [[install:Apache]] -- uses the [[http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html|mod_rewrite]] module. It can be enabled using a ''.htaccess'' file. 
 +  * [[install:IIS]] -- uses custom rewrite rules or the rewrite module 
 +  * [[install:nginx]] -- has built in rewriting support 
 +  * [[install:php-webserver|PHP's built-in web server]] -- needs no configuration, rewrite will work using DokuWiki's index.php router
  
-  * If you want: Change folder name (default is 'dokuwiki' - for example: 'mywiki'). No DokuWiki setting is required. 
-  * If you want: Change default filename 'doku.php' (for example: 'start.php') 
-    - Update filename in file 'index.php' (file in dokuwiki folder)<code php>header("Location: start.php");</code> 
-    - Update filename in <del>'/inc/init.php'</del> '[[devel:preload|inc/preload.php]]' (path in dokuwiki folder). Create the file if it does not exists. ''inc/preload.php'' is not part of default dokuwiki, so it won't be overwritten by a dokuwiki upgrade. <code php><?php 
-if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','start.php');</code> 
  
 +Once the rewriting support has been enabled in the web server, this option can be enabled in the DokuWiki configuration.
  
-That's all!+Select the ''.htaccess'' option in the [[config:userewrite]] config dropdown. Alternatively, in your ''conf/local.php'' file, add or modify the line so it reads:
  
-If you find one more php file to edit, note it here, please. +<code php> 
- +$conf['userewrite'] = 1;
-Regards +
-Bronek +
-===== Option 1: web server ===== +
- +
-:!: Remember to set following in the Configuration Manager ''/start?do=admin&page=config'' +
-  * Use nice URLs: **.htaccess** +
-  * Use slash as namespace separator in URLs [**x**] +
-Otherwise rewrite rules will not be useful. +
- +
- +
-==== Hiawatha ==== +
-→ [[install:hiawatha#URL Rewriting with Hiawatha]] +
-==== Apache ==== +
- +
-Rewriting URLs in Apache is done through the **mod_rewrite** module of [[http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html|Apache 1]] or [[http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html|Apache 2]]. The module is enabled in httpd.conf with the following line (make sure it is not commented out): +
- +
-<code apache> +
-LoadModule rewrite_module modules/mod_rewrite.so+
 </code> </code>
  
-On many kinds of Linux (UbuntuDebian, etc) you may enable mod_rewrite with:+In DokuWiki root folderfind the file ''.htaccess.dist'' and copy it as ''.htaccess''. Edit it and uncomment lines referring to userwrite. It's a short file and easy to understand. 
 +==== Option 2DokuWiki ====
  
-<code bash> 
-sudo a2enmod rewrite 
-</code> 
  
-The setup of module mod_rewrite is done through so-called **rewrite rules**, which can be either defined directly in the server's main config or in a .htaccess file located in DokuWiki's main directory.  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((In Debian 6 at least you do not have to copy anything. ''/usr/share/dokuwiki/.htaccess'' links to ''/etc/dokuwiki/htaccess''. So there is no caveat anymore.))) and uncomment the lines to enable rewriting.+This option won't need any webserver setup. However it relies on the PATH_INFO feature of the CGI standard as implemented by ApacheSome webserver configurations might not support it.
  
-<code apache> +To enable this option, select the ''DokuWiki internal'' option in the [[config:userewrite]] config dropdown. Alternatively, in your ''conf/local.php'' file, add or modify the line so it reads:
-RewriteEngine on+
  
-RewriteBase /dokuwiki +<code php> 
- +$conf['userewrite'] = 2;
-RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L] +
-RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L] +
-RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$ [QSA,L] +
-RewriteRule ^$                        doku.php  [L] +
-RewriteCond %{REQUEST_FILENAME}       !-f +
-RewriteCond %{REQUEST_FILENAME}       !-d +
-RewriteRule (.*)                      doku.php?id=$1  [QSA,L] +
-RewriteRule ^index.php$               doku.php+
 </code> </code>
- 
-On the line ''RewriteBase /dokuwiki'', you need to replace the ''/dokuwiki'' with whatever directory you use in your URL to get to the wiki. Say that your normal (Option 0) URL is http://www.whatever.com/projects/documents/doku.php . You will need to set the above line to ''RewriteBase /projects/documents''. However sometimes this line is not needed at all. 
- 
-=== Some Notes === 
- 
-.htaccess files are only honored if Apache's main config allows it. Many default Apache installs don't. To enable them try adding the following to the httpd.conf: 
- 
-<code apache> 
-<Directory /path/to/dokuwiki> 
-   AllowOverride AuthConfig FileInfo Limit 
-</Directory> 
-</code> 
- 
-PS: The above will ''AllowOverride'' only what is needed for the default config to work. If it does not work for you, try using ''AllowOverride All'' 
- 
-Alternatively you may simply specify the rewrite rules mentioned above directly in the httpd.conf: 
- 
-<code apache> 
-<Directory /path/to/dokuwiki> 
-  RewriteEngine on 
-  ... rewrite rules here ... 
-</Directory> 
-</code> 
- 
-You may have to restart Apache for these changes to work. 
- 
- 
-Some users reported getting a "403 - Forbidden" Error after enabling the rewrite support. Setting the FollowSymlinks option seems to solve the problem: 
- 
-<code apache> 
-Options +FollowSymlinks 
-RewriteEngine on 
- 
-...etc. 
-</code> 
- 
-The rewrite rules given above will map all non-existing files and directories to the DokuWiki main dispatcher, this may apply to virtual mappings (aliases). Some host sites map web access statistics to a virtual /stats directory. To be able to still access these virtual directories, you need to exclude them in the rewrite conditions. Example: 
- 
-<code apache> 
-... 
-RewriteCond %{REQUEST_FILENAME}       !-f 
-RewriteCond %{REQUEST_FILENAME}       !-d 
-RewriteCond %{REQUEST_URI} !^/stats/(.*)$ 
-... 
-</code> 
- 
-If you're running without a RewriteBase, perhaps because you're hosting under a dedicated VirtualHost, you must modify the rewrite rules accordingly. 
- 
-<code apache> 
-RewriteRule ^/_media/(.*)  %{DOCUMENT_ROOT}/lib/exe/fetch.php?media=$1  [QSA,L] 
-RewriteRule ^/_detail/(.*) %{DOCUMENT_ROOT}/lib/exe/detail.php?media=$1  [QSA,L] 
-RewriteRule ^/_export/([^/]+)/(.*) %{DOCUMENT_ROOT}/doku.php?do=export_$1&id=$2  [QSA,L] 
-RewriteRule ^/$ %{DOCUMENT_ROOT}/doku.php [L] 
-RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f 
-RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d 
-RewriteRule (.*) /doku.php?id=$1  [QSA,L] 
-</code> 
- 
-Each RewriteRule stanza must have a leading slash included, or Apache will return a 400 response code. 
- 
-You may need to change  
-If you have a **''robots.txt''** and/or **''sitemap.xml''** file in your document root (for the Google bot) then you must exclude these files from rewriting in your ''.htaccess'' file: 
- 
-<code apache> 
-RewriteCond %{REQUEST_FILENAME}   !robots\.txt 
-RewriteCond %{REQUEST_FILENAME}   !sitemap\.xml 
-</code> 
- 
-If the URLs are still not rewriting correctly, double-check that this setting is actually set correctly.  In the config settings page, check that "Use nice URLs" is set to ".htaccess" in your config settings.  Or, double-check that $conf['userewrite'] is set to '1' in conf/local.php . 
- 
-== Apachectl status broken == 
- 
-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 
- 
-  RewriteCond %{REQUEST_URI} !^/server-status$ 
- 
-or creating an empty server-status file in dokuwiki root folder where doku.php is located. see forum post [[http://forum.dokuwiki.org/post/32858 | Apachectl status is broken with dokuwiki]] 
-==== IIS ==== 
- 
-=== URL Rewrite Module for IIS 7 (Microsoft's official) === 
- 
-[[http://learn.iis.net/page.aspx/737/url-rewrite-module-2/|URL Rewrite Module]] is a Microsoft-supported rewrite module that can be installed on IIS 7 and newer. Starting from version 2.0 it has a wizard that will convert .htaccess rules to its own format (it uses standard IIS configuration mechanism which stores the site-specific settings into a ''web.config'' file in the root folder). 
- 
-How to configure it for DokuWiki: 
- 
-  - Make sure you have the .htaccess file configured as described for Apache above 
-  - Install [[http://www.iis.net/downloads/microsoft/url-rewrite|URL Rewrite Module 2.0]] from Microsoft's website. 
-  - In IIS Manager, navigate to the site that hosts DokuWiki and double-click "URL Rewrite" 
-  - In the right pane ("action pane"), find "Import Rules..." and click it 
-  - Select the .htaccess file and click Import 
-  - It may report an error that a RewriteBase rule is not supported. If you see this error, comment out the line in htaccess rewrite rules and run the import again 
-  - If the import succeeded, click Apply in the actions pane 
-  - In your DokuWiki configuration, set [[config:userewrite]] to 1 (in the web UI, it will be seen as ".htaccess") 
- 
-This procedure worked on my installation where DokuWiki was installed in the website root. It also works if Dokuwiki is installed in a subfolder. 
- 
-=== ISAPI Rewrite Lite == 
- 
-IIS 6 and below don't come standard with a rewrite module. I used [[http://www.isapirewrite.com/|ISAPI Rewrite Lite]] (free) successful with these rewrite rules (see the file ''%%C:\Program Files\Helicon\ISAPI_Rewrite\httpd.ini%%''): 
- 
-<code apache> 
-# Dokuwiki rules 
-# Fix RSS Feeds 
-RewriteRule ^(/wiki/)feed.php $1/feed.php [I,L] 
-RewriteRule ^(/wiki/)feed.php\?(.*) $1/feed.php\?mode=$2&$3 [I,L] 
- 
-RewriteRule ^(/wiki/)_media/(.*)\?(.*) $1lib/exe/fetch.php\?media=$2&$3 [I,L] 
-RewriteRule ^(/wiki/)_detail/(.*)\?(.*) $1lib/exe/detail.php\?media=$2&$3 [I,L] 
-RewriteRule ^(/wiki/)_detail/(.*) $1lib/exe/detail.php\?media=$2 [I,L] 
-RewriteRule ^(/wiki/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 [I,L] 
- 
-RewriteRule (/wiki/) $1doku.php [I,L] 
- 
-RewriteRule ^(/wiki/)\?idx=(.*) $1doku.php\?idx=$2 [I,L] 
-RewriteRule ^(/wiki/)lib/(.*) $1lib/$2 [I,L] 
-RewriteRule ^(/wiki/)(.*)\?do=(.*) $1doku.php\?id=$2&do=$3 [I,L] 
-RewriteRule ^(/wiki/)doku.php\?id=(.*) $1doku.php\?id=$2 [I,L] 
-RewriteRule ^(/wiki/)(.*) $1doku.php\?id=$2 [I,L] 
- 
-# this rule fixes a problem to see the old revisions 
-RewriteRule ^(/wiki/)(.*)\?(.*) $1doku.php\?id=$2&$3 [I,L] 
- 
-# Diff still broken unless none is selected under 'use nice URL' options. You can still enter and link to nice URLs but the DokuWiki program will use normal naming. 
-</code> 
- 
-For all lines with ''RewriteRule ^(/wiki/)'', you need to replace the ''(/wiki/)'' with whatever directory you use in your URL to get to the wiki. Say that your normal (Option 0) URL is http://www.whatever.com/projects/documents/doku.php . You will need to set the above line to ''^(/projects/documents/)''. 
- 
-=== Ionics Isapi Rewrite Filter === 
- 
-It is also possible to use [[http://www.codeplex.com/IIRF|Ionics Isapi Rewrite Filter]], which is free and open-source. 
- 
-<code apache> 
-IterationLimit 1 
- 
-RewriteRule ^/_media/(.*)             /lib/exe/fetch.php?media=$1   [QSA,L] 
-RewriteRule ^/_detail/(.*)            /lib/exe/detail.php?media=$1  [QSA,L] 
-RewriteRule ^/_export/([^/]+)/(.*)    /doku.php?do=export_$1&id=$2  [QSA,L] 
-RewriteRule ^/$                       /doku.php                     [QSA,L] 
-# infinite redirect fix 
-RewriteCond %{REQUEST_FILENAME}       !-d 
-RewriteRule ^/(.*)/                 /doku.php?id=$1               [QSA,L] 
-# end fix 
-RewriteCond %{REQUEST_FILENAME}       !-f 
-RewriteCond %{REQUEST_FILENAME}       !-d 
-RewriteRule ^/(.*)                    /doku.php?id=$1               [QSA,L] 
-</code> 
- 
-==== Lighttpd ==== 
- 
-Assuming you have followed [[:install:lighttpd|instructions]] for how to set up dokuwiki under lighttpd.  If you haven't, define var.dokudir as shown in the example. 
- 
-<code bash> 
- 
-# We assume here that the wiki is accessible via http://wiki.example.com/dokuwiki/ 
-var.dokudir = "/dokuwiki" 
- 
-# rewrites for dokuwiki 
-$HTTP["url"] =~ "^" + var.dokudir { index-file.names = ("doku.php") } 
-    url.rewrite = ( 
-      "^" + var.dokudir + "/lib/.*$"              => "$0", 
-      "^" + var.dokudir + "/_media/(.*)?\?(.*)$"  => var.dokudir + "/lib/exe/fetch.php?media=$1&$2", 
-      "^" + var.dokudir + "/_media/(.*)$"         => var.dokudir + "/lib/exe/fetch.php?media=$1", 
-      "^" + var.dokudir + "/_detail/(.*)?\?(.*)$" => var.dokudir + "/lib/exe/detail.php?media=$1&$2", 
-      "^" + var.dokudir + "/_detail/(.*)?$"       => var.dokudir + "/lib/exe/detail.php?media=$1", 
-      "^" + var.dokudir + "/_export/([^/]+)/(.*)\?(.*)$" => var.dokudir + "/doku.php?do=export_$1&id=$2&$3", 
-      "^" + var.dokudir + "/_export/([^/]+)/(.*)" => var.dokudir + "/doku.php?do=export_$1&id=$2", 
-      "^" + var.dokudir + "/doku.php.*"           => "$0", 
-      "^" + var.dokudir + "/feed.php.*"           => "$0", 
-      "^" + var.dokudir + "/(.*)\?(.*)"           => var.dokudir + "/doku.php?id=$1&$2", 
-      "^" + var.dokudir + "/(.*)"                 => var.dokudir + "/doku.php?id=$1" 
-    ) 
-</code> 
- 
-Enable the rewrite module in lighttpd.conf by adding "mod_rewrite" in server.modules. An example config can be seen [[:install:lighttpd_config_example|here]]. 
-==== Nginx ==== 
- 
-Nginx is a very fast and stable httpd, see more about [[http://nginx.org/|nginx project]], and an English [[http://wiki.nginx.org/|wiki]]. In the following example, our server root is /var/www, and we extract dokuwiki to /var/www/dokuwiki. 
- 
-For NGINX 0.7.65 or later ( [[http://wiki.nginx.org/Dokuwiki|config source]] ) 
-<code> 
-server { 
-        server_name wiki.domain.tld; 
-        root /var/www/dokuwiki; 
-  
-        location / { 
-                index doku.php; 
-                try_files $uri $uri/ @dokuwiki; 
-        } 
-  
-        location @dokuwiki { 
-                rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; 
-                rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; 
-                rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; 
-                rewrite ^/(.*) /doku.php?id=$1 last; 
-        } 
-  
-        location ~ \.php$ { 
-                include fastcgi_params; 
-                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
-                fastcgi_pass unix:/tmp/phpcgi.socket; 
-        } 
-} 
-</code> 
- 
-For NGINX 0.6.x or later (tested up to 0.7.65) 
-<code> 
-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   /var/www/wiki/; 
-   index  index.html index.php; 
- 
-   location / { 
-    if (-f $request_filename) { 
-      break; 
-     } 
- 
-     if (!-f $request_filename) { 
-        #dokuwiki is installed in the root of the site 
-        rewrite ^/(.*)?(.*)  /doku.php?id=$1&$2 last; 
-        rewrite ^/$ /doku.php last; 
-        break; 
-               
-   } 
- 
-   #dokuwiki is installed in the root of the site 
-   rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; 
-   rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; 
-   rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; 
- 
-   location ~ \.php$ { 
-    fastcgi_pass   phpfcgi; 
-    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
-    include        fastcgi_params; 
-   } 
-} 
-</code> 
- 
-For nginx 0.7.27 or later (with try_files support) 
-<code> 
-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 /var/www/wiki; 
-    index doku.php; 
- 
-    location / { try_files $uri $uri/ @dokuwiki; } 
- 
-    location @dokuwiki { 
-        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; 
-        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; 
-        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; 
-        rewrite ^/(.*) /doku.php?id=$1&$args last; 
-    } 
- 
-    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:9000; 
-    } 
-} 
-</code> 
- 
-For nginx 0.7.27 or later (with try_files support & dokuwiki is installed in the root of the site) 
- 
-<code>server { 
-        listen   80; 
-        root /var/www; 
-        server_name yourdomain.net; 
- 
-        location / { 
-                try_files $uri $uri/ @dk; 
-                rewrite ^/$ /doku.php last; 
-        } 
- 
-        location @dk { 
-                rewrite ^/(.*) /doku.php?id=$1 last; 
-        } 
- 
-        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; 
-        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; 
-        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; 
- 
-        include common.conf; # other settings like php-fpm. 
-} 
-</code> 
-=== Notes === 
- 
-Nginx has complete support for fastcgi, please reference [[http://wiki.codemongers.com/NginxHttpFcgiModule|nginx fastcgi]] document to fit your setup. 
- 
-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 like this: 
-  server { 
-    listen 443; 
-    ... 
-    location ~ .php$ { 
-      ... 
-      include fastcgi_params; 
-    ## sets $_SERVER['HTTPS'] 
-      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/local.php file, add or modify the line so it reads: 
- 
-| $conf['userewrite'] = 2; | 
- 
-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>718|known not to work]] with this setting((See [[#Discussion]])). IIS6 (MS Server 2003) works pretty fine, when ''basedir'' is set to ''/''. 
- 
-Using Apache's **Alias directive** with this option can lead to severe headaches and broken wiki! <= A patch which should solve this problem is available here: [[https://www.trg-oha.de/~sstrickroth/dokuwiki-alias.patch]] 
- 
  
  
Line 423: Line 63:
 This parameter is the PHP session ID and gets added by PHP automatically. It's completely unrelated to rewriting. To avoid it you can force PHP to always use cookies for sessions by setting the ''session.use_only_cookies'' option for PHP. This parameter is the PHP session ID and gets added by PHP automatically. It's completely unrelated to rewriting. To avoid it you can force PHP to always use cookies for sessions by setting the ''session.use_only_cookies'' option for PHP.
  
-This is usually done in the php.ini config file (when using a web hoster check their support page if and how you can edit these values):+This is usually done in the php.ini config file:
  
 <code ini> <code ini>
Line 429: Line 69:
 </code> </code>
  
-If session id still work try:+You can also try:
 <code ini> <code ini>
 session.use_trans_sid=0 session.use_trans_sid=0
 </code> </code>
  
-When your PHP is used as Apache module you may be able to tweak these values using a .htaccess file using the following syntax:+====== See Also ======
  
-<code> 
-php_flag session.use_only_cookies on 
-php_flag session.use_trans_sid off 
-</code> 
- 
-If you cannot use either of these solutions (many web hosts prevent editing php.ini and the use of php_flag in .htaccess), you will need to edit conf/local.php. Note that the above settings cannot be changed using ini_set() since PHP version 4.2.3, so the **only** way to do this is to use 
- 
-<code php> 
-ini_set('url_rewriter.tags', ''); 
-</code> 
- 
-> My problem was that my **session.cookie_domain** was incorrectly set (I'm doing virtual hosting, and the domain name was incorrect). I added <code>php_value session.cookie_domain www.my.domain.com</code> to the appropriate virtualhost in my httpd.conf (though .htaccess would probably work just as well), and the polluted URLs disappeared. Also, if you can't get to your php.ini or apache config, you should be able to use **ini_set('PHP variable', 'value');** to the same effect (it seems that conf/local.php is a good place to put this, as the file is included before the session is started). 
- 
-> In my case, FastCGI was causing session IDs to appear. Disabling it removed them. 
- 
-====== Also see ====== 
   * [[:tips:httpslogin|Rewrite rules for secure login]]   * [[:tips:httpslogin|Rewrite rules for secure login]]
 +  * [[https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules | Tips for debugging .htaccess rewrite rules]]
  
-====== Discussion ====== 
-  * I'm using an nginx setup with ispconfig3, where the rewrite directives are all done through an interface. I'm not sure if you can use even use the server block, but mine ended up looking like this (with wiki installed in domain.com/wikifolder/)<code> 
-location /wikifolder/ { 
- index doku.php; 
- try_files $uri $uri/ @namethisanything; 
-} 
- 
-location @namethisanything { 
- rewrite ^/wikifolder/_media/(.*) /wikifolder/lib/exe/fetch.php?media=$1 last; 
- rewrite ^/wikifolder/_detail/(.*) /wikifolder/lib/exe/detail.php?media=$1 last; 
- rewrite ^/wikifolder/_export/([^/]+)/(.*) /wikifolder/doku.php?do=export_$1&id=$2 last; 
- rewrite ^/wikifolder/(.*) /wikifolder/doku.php?id=$1 last; 
-}</code> I don't know if omitting the **location ~ \.php$ {** block from the example above will cause any problems but things seem ok so far... 
- 
-  * I'm using IIRF under IIS6 and the search box always redirected me back to /doku.php. I'm not sure if it's just my config, but the way I fixed it was to add the rule ''RewriteRule ^/\?(.*) /doku.php?$1 [QSA,L]'' underneath the ''_export'' rule. 
-  * Please note that it took me a few hours to figure out all by myself that I needed to add  <code>$conf['userewrite'] = 1;</code> in my conf/local.php file.  I almost erased my Dokuwiki installation because of those two little missing details. --- //bstp 2010-11-26// 
-  * Even when using above configuration with Apache, often the URL becomes example.com/doku.php, no matter at what page you are. I could not find a solution to that. 
-    * It's an implementation issue, not a rewriting problem.  --- //BlackFog 2007-12-19 15:42// 
-  * Option = 2 works with IIS 6 (Windows 2003) and current nightly build if ''basedir'' is set. --- //BlackFog 2007-12-19 15:42// 
-  * For Option = 2, it seems that we need to specify the value of ''basedir'' no matter which system we are using (Apache or IIS, etc); even when ''doku.php'' is just in the root dir we still need to specify ''basedir'' as ''/'' --- //[[xie@yihui.name|Yihui Xie]] 2008/05/28 20:09// 
-  * For a long time I used DokuWiki (2) rewrite option, and now there are some links like ''.../wiki/doku.php/...'' spread through the internet. If now I'll use ''.htaccess'' rewrite method (1), which is discussed here, all those old links with ''doku.php'' will become invalid. Is it possible to add some rules so that old links were still valid? If yes, please, explain how can it be done.  
-    * The solution was to add ''RewriteRule doku.php/(.*)             doku.php?id=$1  [QSA,L]'' right after ''RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]'' line. 
-  * Using rewrite rules for nginx that are presented breaks retrieval of images from dokuwiki. It seems to be not using the default value of root:<code> 
-[error] 27613#0: *1 open() "/usr/local/nginx/html/wiki/lib/tpl/arctic/images/button-firefox.png" failed</code> My solutions is to add the following to the nginx.conf:<code> 
-location /wiki/lib/ { 
-  root /var/www/path/to/site.../; 
-}</code> --- //thedimi.net 2009-03-06 00:00// 
-  * With IIS and Helicon Isapi_Rewrite, if DokuWiki is in the root, the code for httpd.ini should be (note the absence of the subdirectory and the fact that there are 2 lines for "_media" and not just 1 as mentioned in the code above): <code> 
-# Dokuwiki rules 
-# Fix RSS Feeds 
-RewriteRule ^(/)feed.php $1/feed.php [I,L] 
-RewriteRule ^(/)feed.php\?(.*) $1/feed.php\?mode=$2&$3 [I,L] 
-  
-RewriteRule ^(/)_media/(.*)\?(.*) $1lib/exe/fetch.php\?media=$2&$3 [I,L] 
-RewriteRule ^(/)_media/(.*) $1lib/exe/fetch.php\?media=$2 [I,L] 
-RewriteRule ^(/)_detail/(.*)\?(.*) $1lib/exe/detail.php\?media=$2&$3 [I,L] 
-RewriteRule ^(/)_detail/(.*) $1lib/exe/detail.php\?media=$2 [I,L] 
-RewriteRule ^(/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 [I,L] 
-  
-RewriteRule (/) $1doku.php [I,L] 
-  
-RewriteRule ^(/)\?idx=(.*) $1doku.php\?idx=$2 [I,L] 
-RewriteRule ^(/)lib/(.*) $1lib/$2 [I,L] 
-RewriteRule ^(/)(.*)\?do=(.*) $1doku.php\?id=$2&do=$3 [I,L] 
-RewriteRule ^(/)doku.php\?id=(.*) $1doku.php\?id=$2 [I,L] 
-RewriteRule ^(/)(.*) $1doku.php\?id=$2 [I,L] 
-  
-# this rule fixes a problem to see the old revisions 
-RewriteRule ^(/)(.*)\?(.*) $1doku.php\?id=$2&$3 [I,L] 
-  
-# Diff still broken unless none is selected under 'use nice URL' options. You can still enter and link to nice URLs but the DokuWiki program will use normal naming.</code> 
- 
-  * I've put dokuwiki in its own subdirectory, but I want it to use root domain for all requests ''example.com/'' instead of ''example.com/dokuwiki/''. The problem is all links are rewritten back to ''example.com/dokuwiki/samplepage'' and if I set basedir to ''/'' then css and javascript is broken. I can't figure out how to modify my htaccess to get it to work without moving dokuwiki files to root directory. 
-    *Try this tip: via php instead of htaccess, your example.com/index.php can pre-parse example.com/dokuwiki/doku.php in its own folder (thus generating correct links) and echo the resulting html. Worked for me. 
- 
-  * Apache methods works as advertised for LiteSpeed V6.2  
rewrite.1398778645.txt.gz · Last modified: 2014-04-29 15:37 by 207.172.223.242

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki