Skip to content

Url Rewriting with COPS

mikespub edited this page Oct 16, 2024 · 13 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 can use Route Urls in COPS 3.x or enable Url Rewriting (cops_use_url_rewriting) in config/local.php for earlier versions. Additionally, you might need to add some additional lines to the configuration of your http server.

  • Nginx :
      location /download/ {
          rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /index.php/fetch/$2/$1/ignore.$3 last;
          rewrite ^/download/(\d+)/.*\.(.*)$ /index.php/fetch/0/$1/ignore.$2 last;
          break;
      }

      location /view/ {
          rewrite ^/view/(\d+)/(\d+)/.*\.(.*)$ /index.php/inline/$2/$1/ignore.$3 last;
          rewrite ^/view/(\d+)/.*\.(.*)$ /index.php/inline/0/$1/ignore.$2 last;
          break;
      }
  • Apache : Should work out of the box with the supplied .htaccess in versions of Apache below 2.3.9. For newer versions of Apache you need to change AllowOverride none to AllowOverride All in an Apache config file.

  • Cherokee (Thanks to Christophe) :

    • Add a Behavior of type Regular Expression : /cops/download/(.*)/.*\.(.*)$
    • Choose the handler Redirection
    • Add the substitution regexp : /cops/download/(.*)/.*\.(.*)$" --> "/cops/index.php/fetch/0/$1/ignore.$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/index.php/fetch/0/$1/ignore.$2", 
"^/cops/download/(\d+)/(\d+)/.*\.(.*)$" => "/cops/index.php/fetch/$2/$1/ignore.$3")