2

I have a very simple Node.js blog system running on OpenShift. When it reads metadata for a blog entry, it saves the title after passing it through encodeURIComponent. That percent-encoded string is then used as the post "key" in the URL.

For example:

  • I write a blog post, titled "post/with/slashes"
  • My blogging system reads the title from the metadata, and saves the blog post udner "post%2Fwith%2Fslahes"
  • My loving readers go to my-blog.io/post/post%2Fwith%2Fslahes in their web browsers

I'm using Express, and first of all I noticed that Express decodes the URL string before passing to my app (that is, my code finds the string "post/with/slashes" in the request parameters). So I pass it through encodeURIComponent again before looking up the post. I don't think that's relevant, but I've mentioned it just in case.

My problem: When I run a local instance (this is "standalone" Node.js, no Apache going on), this works fine. Express passes me "post/with/slashes", I pass that string through encodeURIComponent and I look up the post. But when I deploy to OpenShift, the request does not reach my app at all. I am served OpenShift's default 404 page, which says "The requested URL /post/post/with/slashes was not found on this server."

In summary: it looks like Apache is decoding the percent-encoded URL before passing it to Node.js. Since there are now slashes in the URL, Express doesn't know how to route the request to my app. Is this expected (and if so why)? If not, why might it be happening and what could I do about it?

Brendan
  • 1,995
  • 1
  • 20
  • 35
  • do you know if apache rewrite is on in your configs? you can disable it for that particular url if that's what's clogging things up. check your .htaccess files. – Jason Nichols Mar 25 '14 at 01:33
  • I don't have any .htaccess files (I didn't even know Apache was running until I encountered this error!), and I don't have access to httpd.conf – Brendan Mar 25 '14 at 21:29
  • 1
    Kind of a duplicate of this question: http://stackoverflow.com/questions/9206835/2f-in-url-breaks-and-does-not-reference-to-the-php-file-required I know it's an old question, but I got here from Google, so I'll post it for future references. – Gray Fox Jan 24 '16 at 15:52
  • Thanks. I won't mark this as a duplicate, since it's specifically about OpenShift, which might be a useful Google keyword for someone with the same problem I had. – Brendan Feb 05 '16 at 17:47

0 Answers0