Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Mod rewrite problems



4:07 pm on Dec 21, 2012 (gmt 0)

- We have a php app located at www.example.com/go
- We have a vhost and subdomain at go.example.com that points to www.example.com/go
- One of the app resources is /api - this can be called at go.example.com/api with some extra uri segments. Examples: go.example.com/api/reports and go.example.com/api/contacts
- All of the above works 100%

What we would now like to achieve is to instead have 'api' as a subdomain. So, instead of the api root being go.example.com/api, we'd like this to be api.example.com.

1. Do we have to get api.example.com to rewrite to go.example.com/api, or to www.example.com/go/api?

2. What .htaccess rules do we need to set up?

3. Do we need to set up a vhost for api.example.com? If yes, where does this vhost need to point to?

Thanks for any advice you can give.


4:17 pm on Dec 21, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

1. The rewrite will look for URL requests asking for api.example.com and the rule target will be the internal filename in the server filesystem where the content resides (this target will NOT contain a hostname, this target is an internal target not a URL out there on the web).

2a. You will need an internal rewrite to fulfil requests for api.example.com and it will need to go in the folder wherever those requests resolve to.

2b. You will also need additional rules to redirect requests for www.example.com/api and others to the new URL. Those rules will be in a different htaccess file.

3. How is the go. subdomain set up? You'll need a similar set up for api. subdomain.

In order to get your head round this, you will need to know which things are URLs used "out there" on the web and which things are internal folders and files used "here" inside the server. They are not at all the same thing.

Featured Threads

Hot Threads This Week

Hot Threads This Month