# Add prefix to all urls?

**URL:** <https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225>\
**Category:** Rails\
**Created:** [November 13, 2008, 5:07pm UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225 "2008-11-13T17:07:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 13, 2008, 5:07pm UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225/1 "2008-11-13T17:07:30Z")

</div>

hi  
i want to add a prefix to all urls in my project

for example ,now i have like this  
“[http://localhost:3000/posts](http://localhost:3000/posts)”

but  
i want like this  
“[http://localhost:3000/my\_blog/posts](http://localhost:3000/my_blog/posts)”  
“[http://localhost:3000/my\_blog/posts/new](http://localhost:3000/my_blog/posts/new)”  
“[http://localhost:3000/my\_blog/posts/edit/1](http://localhost:3000/my_blog/posts/edit/1)”  
“[http://localhost:3000/my\_blog/\*/](http://localhost:3000/my_blog/*/)\*…”

“my\_blog” prefix should come all of my blog project link

how to do that ?

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 13, 2008, 5:12pm UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225/2 "2008-11-13T17:12:49Z")

</div>

Hello Thani,

Try something like this:

map.resources :posts, :path\_prefix =\> ‘/my\_blog’

Hope it helps,

Elías

On Nov 13, 11:07 am, Thani A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 13, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225/3 "2008-11-13T17:22:15Z")

</div>

Thani A. wrote:

> “[http://localhost:3000/my\_blog/posts/new](http://localhost:3000/my_blog/posts/new)”  
> “[http://localhost:3000/my\_blog/posts/edit/1](http://localhost:3000/my_blog/posts/edit/1)”  
> “[http://localhost:3000/my\_blog/\*/](http://localhost:3000/my_blog/*/)\*…”
> 
> “my\_blog” prefix should come all of my blog project link
> 
> how to do that ?

If your using apache you might look into mod\_rewrite.

–  
Jack C.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 14, 2008, 6:11am UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225/4 "2008-11-14T06:11:41Z")

</div>

Elias O. wrote:

> Hello Thani,
> 
> Try something like this:
> 
> map.resources :posts, :path\_prefix =\> ‘/my\_blog’
> 
> Hope it helps,
> 
> Elï¿½as
> 
> On Nov 13, 11:07ï¿½am, Thani A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

if i want to use all of my roots then what should i do ?

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 14, 2008, 5:58am UTC](https://www.ruby-forum.com/t/add-prefix-to-all-urls/153225/5 "2008-11-14T05:58:44Z")

</div>

Jack C. wrote:

> If your using apache you might look into mod\_rewrite.
> 
> –  
> Jack C.  
> removed\_email\_address@domain.invalid

thanks all of you…

i am using apache  
how could i change mod\_write
