Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3991886
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:40:10+00:00 2026-05-20T06:40:10+00:00

I have my web site run out of a Couch DB instance, so I

  • 0

I have my web site run out of a Couch DB instance, so I have my vhost configured to point to /dbname/_design/app/_rewrite.

I want to be able to access the index page from a web browser, while still accessing the Couch DB API over Ajax, so I set up a pair of rewrite rules in my rewrites field:

[ { "from": "/dbname/*", "to: ../../*" },
  { "from": "/*", "to: *" } ]

These rules work fine: I can access individual documents through a /dbname/docname URL, and I can point my web browser at the root of the site and access my attachments that way.

I’d now like to access the information on the database itself, in order to pass a since parameter to the _changes API.

  1. /dbname/ works fine
  2. /dbname/?name=value doesn’t redirect properly. In the Couch DB log, I see lines like 'GET' /dbname/_design/..?name=value 404, whereas I’d expect to see 'GET' /dbname/?name=value 200.

The second case is needed for Ajax from IE, where the jquery.couch.js code adds a fake query string to avoid caching.

How can I phrase my rewrite rules so that Couch DB rewrites /dbname/?name=value correctly?

Edit: To clarify, query strings work OK as long as there is something after the last / in the URL.

  • /dbname/docname?rev=xxx works
  • /dbname/_changes?since=1 works
  • /dbname/?_=dummy doesn’t work; it rewrites to /dbname/_design/..?_=dummy
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:40:11+00:00Added an answer on May 20, 2026 at 6:40 am

    I tried to duplicate your problem but it is working. Below is my interaction. (Note, I use the IP address, 127.0.0.1:5984, to ensure no vhost/rewrite problems, then I access the “production” site via localhost:5984.

    There is a bug it seems with query parameters being appended to rewrites ending with “..”. Instead of rewriting to ../?key=val it writes to ..?key=val which CouchDB does not parse.

    I do not think it is necessary to query a database URL with parameters. So one workaround is to always make sure you never do that. (E.g. if you blindly append no-op parameters to all queries to simplify the code, you’d have to alter that.)

    Another workaround is to enable rewrite to the root CouchDB URL. This requires setting /_config/httpd/secure_rewrites to false.

    { "from":"/api/*", "to":"../../../*" }
    

    Now you can query http://localhost:5984/api/x?key=val or http://localhost:5984/api/x/_changes?since=5. (You cannot query the root URL with parameters—it’s still the bug, but in a less trafficked place.)

    Following is the initial terminal session:

    $ mkdir t
    $ cd t
    $ curl -XDELETE 127.0.0.1:5984/x 
    {"ok":true}
    $ curl -XPUT 127.0.0.1:5984/x 
    {"ok":true}
    $ curl 127.0.0.1:5984
    {"couchdb":"Welcome","version":"1.0.1"}
    
    $ echo -n _design/test > _id
    $ mkdir shows
    $ echo 'function() { return "hello world!\n" }' > shows/hello.js
    $ cat > rewrites.json
    [ { "from":"/db/*", "to":"../../*" }
    , { "from":"/*"   , "to":"*"}
    ]
    
    $ echo '{}' > .couchapprc
    $ couchapp push http://127.0.0.1:5984/x
    $ curl -XPUT http://127.0.0.1:5984/_config/vhosts/localhost:5984 -d '"/x/_design/test/_rewrite"'
    "/x/_design/test/_rewrite"
    
    $ curl localhost:5984 # This is the design document.
    {"_id":"_design/test","_rev":"1-e523efd669aa5375e711f8e4b764da7a","shows":{"hello":"function() { return \"hello world!\\n\" }"},"couchapp":{"signatures":{},"objects":{},"manifest":["rewrites.json","shows/","shows/hello.js"]},"rewrites":[{"to":"../../*","from":"/db/*"},{"to":"*","from":"/*"}]}
    $ curl localhost:5984/_show/hello
    hello world!
    
    $ curl localhost:5984/db # This is the DB.
    {"db_name":"x","doc_count":1,"doc_del_count":0,"update_seq":1,"purge_seq":0,"compact_running":false,"disk_size":4185,"instance_start_time":"1298269455135987","disk_format_version":5,"committed_update_seq":1}
    $ curl localhost:5984/db/_changes
    {"results":[
    {"seq":1,"id":"_design/test","changes":[{"rev":"1-e523efd669aa5375e711f8e4b764da7a"}]}
    ],
    "last_seq":1}
    
    $ curl localhost:5984/db/_changes?since=1 # Parameters accepted!
    {"results":[
    
    ],
    "last_seq":1}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .net 3.5 web site that works fine when I run it
I have a web site that spits out links to third party sites. Now
Here's the setup. I have web site which is essentially a simple CMS. Here
I have a web site (ASP.NET, no MVC) with multiple web forms for filling
I have a web site at http://www.urbanvision.org.uk/ , we have a Twitter feed on
I have a web site that is designed in asp.net and working fine in
I have a web site hosted on IIS with windows authentication. I am trying
I have a web site project with a lot of files, it has become
I have a web site with an API which publishes the information using JSON.
I have a web site and build a wcf service in it. I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.