Forum Moderators: phranque

Message Too Old, No Replies

show a subdomain as a root domain in address bar

         

alexfung

4:33 pm on May 18, 2005 (gmt 0)

10+ Year Member



I had purchased a domains in mydomain.com and rented a webhosting space.

"example.net" is using real DNS pointed to the webhost running Apache.

other 2 domain "alpha.net" and "beta.org" is forwarded to 2 subfolder in hosting.net

if i use real URL forwarding the URL the user can bookmark the subsets, but the URL will show [hosting.net...] or [hosting.net...]

is there any way which I will modify the URL to show alpha.net/index.html or beta.org/index.html in the address bar while subfolders inside the directory will also be shown? Thank you very much.

[edited by: jdMorgan at 4:16 pm (utc) on May 22, 2005]
[edit reason] Examplified. [/edit]

sitz

7:00 pm on May 21, 2005 (gmt 0)

10+ Year Member



suppose it depends on how you define 'url forwarding'. If you have write access to your httpd.conf, you should configure a NameVirtualHost [httpd.apache.org] directive and <VirtualHost> blocks [httpd.apache.org] accordingly. If you don't have write access to your httpd.conf, you can accomplish something similar in your .htaccess file by using mod_rewrite:

RewriteEngine on
#
# prevent loops
RewriteCond %{REQUEST_URI}!^/path/to/documentroot
#
# verify a Host: header exists
RewriteCond %{HTTP_HOST} .
#
# pull the middle bit out of the hostname and store it
# in the %2 backreference
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.[a-z] [NC]
#
# Rewrite!
RewriteRule ^(.*) /path/to/documentroot/%2/$1 [L]

You may want to consider setting up your directories like this:


/path/to/documentroot/alpha.net
/path/to/documentroot/beta.org

...and then changing the lastg RewriteCond above to read like this:


RewriteCond %{HTTP_HOST} ^(www\.)?([^:]+) [NC]

This gives you a little more flexibility, and allows for situations in which you're hosting content for 'alpha.net' and 'alpha.com', which are owned by different people.

Does this help?

alexfung

1:56 pm on May 22, 2005 (gmt 0)

10+ Year Member



Thank you for your reply, I don't have the apache access right now so my only bet is in .htaccess. However i do not too understand how to modify the code you gave me, it gave me an internal server error.

My rootdirectory is example.net and i have 2 webpage, tacticalcombat.info and savekaitak.info

they are stored in the following path
[example.net...]
and
[example.net...]

I have registered all domain name and the hosting provided forwarding function for all domains. Could you further explain how should i rewrite the code? Thank you very much.

[edited by: jdMorgan at 4:17 pm (utc) on May 22, 2005]
[edit reason] Examplified. [/edit]

sitz

6:09 pm on May 23, 2005 (gmt 0)

10+ Year Member



The error is most likely caused by the first RewriteCond like. The software which drives this forum strips spaces out of posts in certain places; like before the '!' character. It should read:

RewriteCond %{REQUEST_URI}[space]!^/path/to/documentroot