subdomain to stay in address bar

Using a single web hosting account to host multiple sites

subdomain to stay in address bar

Postby benoka » Fri Jun 19, 2009 11:40 am

Hi everyone,

I was looking around in the FAQ and search but could not find an exact answer. I'm very new to .htaccess and this is the first site where it seems not only parts of the commands are included in which make me happy.

My request is very simple:

i setup a subdomain on both, domain and hosting level, it all works ok. i just would like to see subdomain.domain.com in the address bar too and not the path I redirected it to. If possible, all pages under this subdomain should appear the same way (i.e.: subdomain.domain.com/contactus.html and not domain.com/folder/folder/contactus.html). As you can see I use .html and don't know anything about php (but I guess it's not needed here).

The domain provider wants to sell me masking, but if .htaccess can do it, why would i pay for it? Although, the fact that they offer this service may also mean that i cannot use .htaccess but as the basic mod_rewrite test was successful, I was thinking the masking service is sold to people who don't bother searching for the solution...

Your help is much appreciated as I was searching through the internet for this answer but could not find anything that really worked.

Thank you very much in advance.

Have a wonderful weekend everyone! ;)
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Fri Jun 19, 2009 2:03 pm

What do you happens when you go to subdomain.example.com at the moment? Do you go to example.com/subdomain/?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Fri Jun 19, 2009 2:12 pm

not exactly, if i type in subdomain.example.com i get to the folder i specified in the forwarding at the hosting, so example.com/folder/folder.
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Sat Jun 20, 2009 8:56 am

And the URL changes to example.com/folder/folder?
What happens without the forwarding set up?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Sun Jun 21, 2009 1:30 am

what forwarding do you mean? on domain or hosting part? if i don't redirect on domain part, it gives an error (if i remember well, it was 500). I haven't tried on hosting, but that would result in having to put my website in the root folder of my main domain, right? do you mean I should do that and then redirect the subdomain requests to a separate folder?
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Sun Jun 21, 2009 10:45 am

If and how this can be done depends on how much control you have of the server and what the default sub domain processing is.

If you have a lot of control you can use <VirtualHost>s to send the sub domains to the correct place. You probably wouldn't even need mod_rewrite.

If don't have a lot of control but you can get the sub domain requests sent to a directory you could use mod_rewrite. But it has to be either / or /folder because mod_rewrite in a .htaccess file can't rewrite outside the current document root (of the sub domain).

If you have mod_proxy and you can get the sub domain to stay in the address bar and run the mod_rewrite you could proxy the request. But it's inefficient compared to proper processing.

So you need to find out what happens without the forwarding. I don't know what forwarding you have so you need to try without all of it and without some of it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Mon Jun 29, 2009 10:56 am

richardk, first of all, thank you for your responses.

ok, the following has been done:

1. i setup a forward on hosting part for the subdomain (hosting is by godaddy for the case you would be familiar with how it works there), meaning i added a subdomain and specified a path to it, i guess it's like shared hosting. if I would not setup forwarding here, my subdomain would display the same pages as my "root" domain, right? - let's say the forward path i have setup in this point is: /websites/subdomain

2. i setup a forward on domain side with setting up the subdomain. this is to say, that at cheapdomain (works exactly like godaddy) when you setup a subdomain you HAVE to give a forward path. this forward path is set to the folder I setup in point 1. - so it's the same as above: /websites/subdomain

this is the only way requests for subdomain.domain.com are getting through. if i don't have this, the response from the browser is 501 (if I remember well), probably stating that the subdomain doesn't exist.

pages uploaded to the above forward path /websites/subdomain are displaying correctly but not as subdomain.domain.com but as domain.com/websites/subdomain in the address bar.

What is <VirtualHost> and where is it to be setup?

hope this helps and thank you for helping!

Have an excellent day!

ben
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Fri Jul 10, 2009 10:25 am

1. i setup a forward on hosting part for the subdomain (hosting is by godaddy for the case you would be familiar with how it works there), meaning i added a subdomain and specified a path to it, i guess it's like shared hosting. if I would not setup forwarding here, my subdomain would display the same pages as my "root" domain, right? - let's say the forward path i have setup in this point is: /websites/subdomain

What happens if you remove it?

2. i setup a forward on domain side with setting up the subdomain. this is to say, that at cheapdomain (works exactly like godaddy) when you setup a subdomain you HAVE to give a forward path. this forward path is set to the folder I setup in point 1. - so it's the same as above: /websites/subdomain

This is most likely the problem. You want straight DNS, eg. set the sub domain to go to an IP address not a URL or path.

What is <VirtualHost> and where is it to be setup?

You can't use it. (You have to have more control of the server.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby benoka » Sun Jul 12, 2009 3:57 am

1. i setup a forward on hosting part for the subdomain...


What happens if you remove it?


I tested it and there's no difference between setting this up or not. redirection is actually made by the domain side forward which cannot be left blank. I tried to simply forward it to the main domain and setup .htaccess to redirect but that didn't help, it's just not doing it. Is it possible that the domain provider doesn't allow this to be able to sell me their "masking" service as they call it?

This is the description of the service: "Masking redirects Web traffic for a domain to a specified URL, preventing the forwarded domain URL from displaying in the browser's address bar."

Of course the company will not tell me how to circumvent this, that's why I'm trying to get help to find out whether it's possible to do it or not before I would buy the service.

2. i setup a forward on domain side...


This is most likely the problem. You want straight DNS, eg. set the sub domain to go to an IP address not a URL or path.


I don't understand what you mean. Where should I set the sub domain to point to an IP?[/quote]
benoka
 
Posts: 23
Joined: Fri Jun 19, 2009 9:23 am

Postby richardk » Sun Jul 12, 2009 2:37 pm

redirection is actually made by the domain side forward which cannot be left blank. I tried to simply forward it to the main domain and setup .htaccess to redirect but that didn't help, it's just not doing it.

Then it doesn't sound like mod_rewrite can help as the redirection happens before mod_rewrite is processed (before the request even gets to the server). How did you get your main domain to work without a redirect? Did you ever enter an IP address or name server address?

Is it possible that the domain provider doesn't allow this to be able to sell me their "masking" service as they call it?

This is the description of the service: "Masking redirects Web traffic for a domain to a specified URL, preventing the forwarded domain URL from displaying in the browser's address bar."

That sounds like they put your site in a <frame>.

I don't understand what you mean. Where should I set the sub domain to point to an IP?

Normally in your domain control panel. (With GoDaddy, in the Total DNS control panel.) I'm starting to think you don't have that option, and that you have to pay extra to do this at cheapdomains.com.au (which is where you have your domain, right?).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 21 guests

cron