# Creating a Shopfy kind of a website - pls help

**URL:** <https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506>\
**Category:** Rails\
**Created:** [November 26, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506 "2009-11-26T13:43:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [November 26, 2009, 1:43pm UTC](https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506/1 "2009-11-26T13:43:56Z")

</div>

Hi All,

I want to create a site like shopfy, where I can hosted it in a central  
place merchants can create their own stores, But I want the following  
functionalities to happen,

I should be able to give each merchant a different url, like

1 - [www.sportsitems.com](http://www.sportsitems.com) , [www.cloths.com](http://www.cloths.com) etc…  
2 - when they access the site their URL should be changed accordingly,  
Ex: if sportsitems user and cloths user is accessing their product  
page it should be like

```
www.sportsitems.com/products
www.cloths.com/products

```

I’m hoping the give each site an id so that I can identify the request  
from each site and cater accordingly…

So please help me and guide me if you think I’m going in a wrong  
direction 😃

thanks in advance,

cheers,  
Sameera

---

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [November 27, 2009, 11:17am UTC](https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506/2 "2009-11-27T11:17:31Z")

</div>

We have a similar system in our website, which is a ‘white label’ site  
which is branded for each of our clients, which are called  
‘music\_services’ in our system. The branding is pretty minimal - each  
music service has their own version of some of the graphics that we use  
on the site (eg some logo gifs) and they also have a url string stored  
in the database as ‘host’.

The main difference between the different sites is the pre sign-in page,  
which differs from music service to music service and effectively  
advertises that site. These are all just wordpress pages (meaning they  
can be edited and changed without having to restart the server or  
anything). So, the home page directs to the wordpress page if you’re  
not logged in, then when you log in you go to the site’s home page,  
which is the same for all music services except for the different logos.

Each user is associated with a particular music service, and when they  
log in we show the relevant graphics for their music service: whichever  
url they happen to be at. So, you can access the site from any of the  
urls. However, you could instead just get the url with request.host (or  
whatever it is) and decide which branding you want to use based on that.

So, anyway, it’s not hard to do but takes a little bit of planning.

---

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [November 30, 2009, 8:14am UTC](https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506/3 "2009-11-30T08:14:51Z")

</div>

Hi Max,

I tried request.host and had no luck, here’s what i did

I hosted my rails app in under the url (I publicly hosted)

[www.site1.com](http://www.site1.com)

and had another domain [www.site2.com](http://www.site2.com) and I forwarded it to  
[www.site1.com](http://www.site1.com) (with masking, so that even if the user is in  
[www.site1.com](http://www.site1.com) his url will say [www.site2.com](http://www.site2.com))

so following scenarios are ok,

if user type [www.site1.com](http://www.site1.com) he/she will go there and in the URL it  
displays as [www.site1.com](http://www.site1.com)

if a user type www…site2.com (which is redirected with masking) he/she  
will ended up in [www.site1.com](http://www.site1.com) , but the URL says [www.site2.com](http://www.site2.com)

But my problem is , in both the cases  
request.host is always [www.site1.com](http://www.site1.com)

A’m I doing something wrong here or what is the best way to do this,

thanks in advance

cheers  
sameera

---

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [November 30, 2009, 12:10pm UTC](https://www.ruby-forum.com/t/creating-a-shopfy-kind-of-a-website-pls-help/179506/4 "2009-11-30T12:10:17Z")

</div>

request.host (or maybe request.host\_with\_port) returns the referrer url,  
ie the url that the browser asked for. So, it should be the same as  
what is in the address bar in the browser.
