Skip to content

Url Rewriting with COPS

Sébastien Lucas edited this page Sep 11, 2013 · 11 revisions

The Kobo eReader Touch's browser cannot download through php file (the extension has to be known). To allow downloading on this eReader, you must enable Url Rewriting (cops_use_url_rewriting).

  • Nginx :
      location /download/ {
          rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last;
          rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
          break;
      }
  • Apache : Should work out of the box with the supplied .htaccess

  • Cherokee (Thanks to Christophe) :

    • Add a Behavior of type Regular Expression : /cops/download/(.*)/.*\.(.*)$
    • Choose the handler Redirection
    • Add the substitution regexp : /cops/download/(.*)/.*\.(.*)$" --> "/cops/fetch.php?data=$1&type=$2
  • Lighttpd (Nas4free) :

    • you have to manually enter the url-rewriting rules from the webserver tab of the web gui. there is a "Auxiliary parameters" texbox in witch you have to enter this string (adjust the path for your specific case) :
url.rewrite-once = ("/cops/download/(.*)/.*\.(.*)$" => "/cops/fetch.php?data=$1&type=$2", 

"^/cops/download/(\d+)/(\d+)/.*\.(.*)$" => "/cops/fetch.php?data=$1&db=$2&type=$3")