Solved

Create a sub domain with .htaccess ???

Posted on 2006-10-26
6
559 Views
Last Modified: 2008-03-10
Hi experts,

I have a web site hosted in a LINUX environment and let’s assume the URL as http://www.abc.com 

Now I need to create a sub domain called http://xyz.abc.com and redirect all the traffic coming to that URL to folder called “xyz” in the root. I'm willing to deploy a application in to "xyz" folder.

Hosting support service has informed me to do it using .htaccess file. Also there is some facility to enter A records, CNAME, etc if needed.

Can you please provide me the necessary guide to this?  

Thanks a lot !
0
Comment
Question by:NetMaxtor
6 Comments
 
LVL 10

Accepted Solution

by:
rivusglobal earned 200 total points
ID: 17810072
Hi NetMaxtor,

You can create the third level domain by entering an A record ( IP address of the webserver ) for the xyz domain.   From there, you can use a mod_rewrite rule in an .htacess file to control the redirection ( instead of having apache do it ).

Put this in your .htaccess file:

Options FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^xyz.abc.com$
RewriteRule ^/(.*) http://abc.com/xyz/$1

That should redirect anything http://xyz.abc.com/folder/page.html to http://abc.com/folder/page.html and other variations.
0
 

Author Comment

by:NetMaxtor
ID: 17810351
i have create a A record to point xyz.abc.com to server IP address (say 123.123.123.123)
And there was not a .htaccess file the root folder /www

I have create new file (used vim) and put it in the root, restarted the apachectl, but still xyz.abc.com directing to the home site (abc.com)

Please advice !
0
 
LVL 15

Assisted Solution

by:periwinkle
periwinkle earned 100 total points
ID: 17811140
Have .htaccess overrides been enabled for abc.com?  Have you checked in the error_log and access_log to see if there is more information available to you about what page is being delivered?
0
 
LVL 1

Assisted Solution

by:FartingUncle
FartingUncle earned 200 total points
ID: 17835657
Also, some ISPs offer sub-domain forwarding, so you can setup xyz.abc.com to point to (relative to web root) /xyz.  Check your control panel to see if that option (or an equivalent) is available (I'm guessing the fact that they advised you to use .htaccess means that it doesn't, but I thought it worth mentioning)
0
 
LVL 1

Assisted Solution

by:FartingUncle
FartingUncle earned 200 total points
ID: 17835687
...also, I'm not sure if the leading slash is always present in the URI.

Try replacing

   RewriteRule ^/(.*) http://abc.com/xyz/$1

With
   RewriteRule ^/?(.*) http://abc.com/xyz/$1
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Forward apache log to Syslog-NG 7 78
PHP temp path missing 4 49
setting up tomcat for external access 4 69
Problem with .htaccess file 4 66
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now