# Using URLs as resource IDs: how to make work with Apache/Passenger?

**URL:** <https://www.ruby-forum.com/t/using-urls-as-resource-ids-how-to-make-work-with-apache-passenger/194983>\
**Category:** Rails\
**Created:** [September 14, 2010, 8:15pm UTC](https://www.ruby-forum.com/t/using-urls-as-resource-ids-how-to-make-work-with-apache-passenger/194983 "2010-09-14T20:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 14, 2010, 8:15pm UTC](https://www.ruby-forum.com/t/using-urls-as-resource-ids-how-to-make-work-with-apache-passenger/194983/1 "2010-09-14T20:15:16Z")

</div>

I have a resource whose public ID is a URL. The resulting URLs look like  
this

[http://my-app.com/things/http%3A%2F%2Fexample.com/foo.png](http://my-app.com/things/http%3A%2F%2Fexample%2Ecom/foo.png)

I make sure manually, that “.” in URLs are encoded as “%2E”. The route  
looks like this

get ‘things/:url’ =\> ‘things#show’

This works just fine with Mongrel, but it does not work with Apache and  
Passenger. The request doesn’t even get through to my app, I only get a  
404 response and a corresponding entry in

/var/log/apache2/other\_vhosts\_access.log

There is nothing in the app’s log. The problem appears to be caused by  
the “/” in the :url parameter, even though they are encoded as “%2F”.

I’d prefer if I didn’t have to read through all the ActionPack and Rack  
routing code to understand what’s happening and find a remedy. It must  
be possible to do this cleanly.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 14, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/using-urls-as-resource-ids-how-to-make-work-with-apache-passenger/194983/2 "2010-09-14T21:23:09Z")

</div>

On Tue, Sep 14, 2010 at 11:13 AM, Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> routing code to understand what’s happening and find a remedy. It must  
> be possible to do this cleanly.

Tricky issue. To fix, enable AllowEncodedSlashes in Apache:  
[http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes](http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes)

jeremy

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [September 14, 2010, 10:12pm UTC](https://www.ruby-forum.com/t/using-urls-as-resource-ids-how-to-make-work-with-apache-passenger/194983/3 "2010-09-14T22:12:20Z")

</div>

On Tuesday 14 September 2010, Jeremy K. wrote:

> On Tue, Sep 14, 2010 at 11:13 AM, Michael S.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
> […]
> 
> > There is nothing in the app’s log. The problem appears to be caused  
> > by the “/” in the :url parameter, even though they are encoded as  
> > “%2F”.
> > 
> > I’d prefer if I didn’t have to read through all the ActionPack and  
> > Rack routing code to understand what’s happening and find a  
> > remedy. It must be possible to do this cleanly.
> 
> Tricky issue. To fix, enable AllowEncodedSlashes in Apache:  
> [core - Apache HTTP Server Version 2.2](http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes)

Thanks, Jeremy, that’s been very helpful. In combination with route  
globbing, i.e.

get ‘things/\*url’ =\> ‘things#show’

the intended controller action is called. Curiously, consecutive slashes  
are collapsed somewhere in parameter processing, so that “[http://foo](http://foo)”  
becomes “http:/foo”. Well, I can work around that, though, of course I’d  
prefer if I didn’t have to.

Are there any security implications of enabling AllowEncodedSlashes? I  
figure there must be a reason that they are not enabled by default.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
