# Eruby - How to get my grubby mittens on the URL?

**URL:** <https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973>\
**Category:** Ruby\
**Created:** [November 1, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973 "2007-11-01T21:05:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 1, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/1 "2007-11-01T21:05:35Z")

</div>

Hi all! 8)

Suppose I have some ruby code in a .rhtml -file, which is processed by  
eruby.

How can I get the url string of the page? (so I can chop it up).

Whats a good place for reference on this?

Csmr

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 1, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/2 "2007-11-01T21:42:25Z")

</div>

> Suppose I have some ruby code in a .rhtml -file, which is processed by  
> eruby.
> 
> How can I get the url string of the page? (so I can chop it up).
> 
> Whats a good place for reference on this?

A good place for reference on it is the Rails list at Google G.:

[http://groups.google.com/group/rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk)

–  
Giles B.

Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)  
Tumblelog: [http://giles.tumblr.com/](http://giles.tumblr.com/)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 1, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/3 "2007-11-01T21:43:35Z")

</div>

Casimir P wrote:

> 

I think this depends somewhat on your environment (it’s different if you  
are running from the command line versus on a web server, for example),  
but try adding

puts ENV.inspect

in your .rhtml file and that should help you find what you need.

-Justin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2007, 9:43am UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/4 "2007-11-03T09:43:16Z")

</div>

On Thu, 01 Nov 2007 15:42:59 -0500, justincollins wrote:

> Casimir P wrote:

> > Suppose I have some ruby code in a .rhtml -file, which is processed by  
> > eruby. How can I get the url string of the page? (so I can chop it up).

> I think this depends somewhat on your environment [deleted some]  
> but try adding
> 
> puts ENV.inspect

Yup. Hehe, kinda simple. Didnt find anything in-depth, but there was  
enough in what I think most call the pickaxe.

> **[Ruby-Doc.org: Documenting the Ruby Language](https://ruby-doc.org/docs/)**
>
> Fast, searchable Ruby documentation for core and standard libraries. Plus, links to tutorials, guides, books, and related sites.

ProgrammingRuby/html/web.html (see code example at the end of “Using  
Eruby”).

What I wanted was to see what URI was requested, the bit after the  
domain,  
ie.:

\<% puts ENV[“REQUEST\_URI”] %\>

Now, if I only could figure out how to redirect _all_ requests to one  
and  
the same .rhtml in the site root without actually rewriting the url user  
sees… Already caused a few infinite redirect loops 8)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2007, 2:24pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/5 "2007-11-03T14:24:33Z")

</div>

On 11/3/07, Casimir P [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> \<% puts ENV[“REQUEST\_URI”] %\>
> 
> Now, if I only could figure out how to redirect _all_ requests to one and  
> the same .rhtml in the site root without actually rewriting the url user  
> sees… Already caused a few infinite redirect loops 8)

For an Apache example, see any rails application (even an empty one),  
go to /public/ and read .htaccess

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 4, 2007, 2:05pm UTC](https://www.ruby-forum.com/t/eruby-how-to-get-my-grubby-mittens-on-the-url/118973/6 "2007-11-04T14:05:57Z")

</div>

On Sat, 03 Nov 2007 08:23:39 -0500, jan.svitok wrote:

> On 11/3/07, Casimir P [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > On Thu, 01 Nov 2007 15:42:59 -0500, justincollins wrote:
> > 
> > > Casimir P wrote:
> > 
> > > > How can I get the url string of the page?
> > > 
> > > puts ENV.inspect

> > ie.: \<% puts ENV[“REQUEST\_URI”] %\>
> > 
> > Now, if I only could figure out how to redirect _all_ requests to one  
> > and the same .rhtml in the site root without actually rewriting the url  
> > user sees… Already caused a few infinite redirect loops 8)
> 
> For an Apache example, see any rails application (even an empty one), go  
> to /public/ and read .htaccess

Afaik rails != eruby, but yeah, .htaccess redirects is how I managed the  
infinite redirect loops 8) something like “RedirectMatch (.\*)  
pageengine.rhtml” etc. 🙂

Just want the user and spiders to see /pagename/ while in fact all  
requests are handled by one file at the root… But this is sorta  
offtopic  
so I guess I’ll take this to regexpo or apache group if I dont get it  
working on my own.

Thanks for the input, everybody.

Csmr
