Roshan Book

My Tech Notebook

Need to show subdomain as url than the directory path


Below is a thread from stackoverflow, where I have asked a question. We did solved it.

Question
I have created a subdomain yesterday as http://www.subdomain.example.com. This has created a directory at the root by the name of subdomain. Now when i open http://www.subdomain.example.com, it gets redirected to http://www.example.com/subdomain. How to keep my url from showing the directory path i.e. in address bar it keep showing http://www.subdomain.example.com , while showing content from the directory subdomain. I have a shared hosting account at hostgator. Thanks for the help

Answer

In your .htaccess file, turn off the redirect and use mod_rewrite:

RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?subdomain.example.com$ RewriteCond %{REQUEST_URI} !^/subdomain RewriteRule ^(.*)$ /subdomain/$1 [L] 

This checks if the requested host is either http://www.subdomain.example.com orsubdomain.example.com makes sure the request doesn’t already start with a /subdomain and appends it otherwise. This redirects internally on the server so your browser doesn’t actually get redirected (address bar will still say: subdomain.example.com).

 

Answer

Just solved the problem, code given by jon is correct. i was trying to upload .htaccess file to root while i should have uploaded to the subdomain directory. One little edit i did to jon code was on line 3rd . I gave full path to the directory . so the 3rd line of the code looked like RewriteContd %{REQUEST_URI)} http://www.example.com/subdomain

36 responses to “Need to show subdomain as url than the directory path

  1. hostgator coupon code 2011 November 15, 2011 at 6:42 pm

    Hostgator.org had been created within 2004 and also since after that has grown coming from a internet service provider along with three hosts to a globe acknowledged web hosting service exceeding Five,1000 computers in its toolbox. Above 1% with the sides web readers are managed through HostGator. Whether or not youre considering starting up a new internet site or maybe searching for fresh hosting possibilities, HostGator will be the program in your case! This runs specifically true using their newest discount codes. In case you even now can’t produce a decision, think about this, the business website hosts buyers including person websites in order to Bundle of money 500 firms.

  2. UGG Roxy Tall Boots 5818 November 18, 2011 at 5:59 am

    excellent issues altogether, you just gained a new reader. What could you suggest about your put up that you simply made a few days in the past? Any sure?

  3. TimonWolfe November 19, 2011 at 11:10 pm

    Hi, I must say that you have made some good points in the post. Thanks for sharing this information.

  4. Hermes Replica November 19, 2011 at 11:51 pm

    I cant believe the amount of wonderful information you have on your blog. I’ve learned a great deal from it. Will be coming back soon.

  5. Cheap Louis Vuitton Bags November 21, 2011 at 11:32 am

    Hello guys, wonderful web page, particularly rich in content and appropriately carefully thought out, personally I found here substantially interesting and useful

  6. Louis Vuitton Handbags Cheap November 22, 2011 at 1:10 am

    You are my intake , I’ve few blogs and often run out from to post .

  7. Burberry Outlet Online November 22, 2011 at 1:41 am

    Really educational cheers, I reckon your current visitors could perhaps want far more writing like that carry on the remarkable work.

  8. Louis Vuitton Sale UK November 23, 2011 at 12:42 am

    Hello, I used to be researching the internet and I revealed your web webpage. Maintain up the outstanding work.

  9. Designer Handbags November 23, 2011 at 12:42 am

    Not long ago i came accross your internet internet site and have been reading along. I figured I might leave my quite first comment. Nice blog. I will keep visiting this web page quite frequently. Thank you

  10. Cheap Designer Handbags November 24, 2011 at 2:59 am

    Truly illuminating appreciate it, I’m sure your trusty readers may well really well want a excellent deal more writing such as this preserve the amazing content.

  11. Burberry Outlet Online November 24, 2011 at 2:50 pm

    I’m a huge lover of your blog! Look at my internet site, You can check your web site there!

  12. Louis Vuitton Knockoffs Cheap November 25, 2011 at 11:23 am

    Hello guys, outstanding website, Thank you rather substantially for the information and facts I really appreciate it!!

  13. Burberry Outlet November 26, 2011 at 3:20 am

    I do not grant all, but I do congratulate the writer of the blog for the theme.

  14. Louis Vuitton wallets Sale November 26, 2011 at 11:35 am

    Hello, I used to be researching the internet and I revealed your web webpage. Maintain up the outstanding work.

  15. Cheap Louis Vuitton Bags November 27, 2011 at 2:42 am

    I wish more men and women would write blogs like this that are actually beneficial to read. With all of the rubbish floating around on the net, it is refreshing to read a blog like yours instead.

  16. Chanel Handbags Replica November 29, 2011 at 2:49 am

    oh neat, this answers is definitely helpful and without a doubt is thoughts suitable! hehe. I’m going to watch if I will be able to have a shot at to utilize most of these details for my own personal blog page. Bless you!

  17. Burberry Outlet Online November 29, 2011 at 4:34 am

    This was extremely interesting and helpful, I have bookmarked and hope to check back to your web page again.

  18. Louis Vuitton Bags November 29, 2011 at 11:48 am

    Keep up this excellent work, you have a good blog over here with a lot great details! When you post some new stuff, I’ll visit your blog again and I’ll follow it.

  19. Louis Vuitton Shoes Outlet November 30, 2011 at 2:46 am

    While this subject can be pretty touchy for most people, my opinion is that there has to be a middle or common ground that we all can find. I do appreciate that youve added relevant and intelligent commentary here though. Thank you!

  20. replica louis vuitton November 30, 2011 at 4:21 am

    You have wonderfully written the post. We have liked your way of penning this. Thank you for sharing this.

  21. Louis Vuitton wallets Sale December 1, 2011 at 1:59 pm

    Some genuinely interesting information and facts, well written and loosely user pleasant.

  22. Louis Vuitton Replica Glasses December 2, 2011 at 10:02 am

    i have been reading your weblog from sometime and i must say you always maintain wonderful consistency,hence i always get pleasure from reading your blog.

  23. Louis Vuitton Handbags Sale December 2, 2011 at 10:34 am

    There is obviously a bundle to know about this. I think you made certain good points in features also.

  24. Pingback: Elektrische Zahnbuerste

  25. Elektrische Zahnbuerste December 5, 2011 at 2:45 am

    Pretty part of content. I just stumbled upon your weblog and in accession capital to assert that I get really loved account your weblog posts. Any way Ill be subscribing on your feeds or even I success you access constantly quick.

  26. Burberry Outlet December 5, 2011 at 4:55 am

    I definitely take pleasure in looking through on this web website , it holds fantastic articles .

  27. Hermes Sale December 5, 2011 at 2:01 pm

    This blog is wonderful. There is always all of the suitable facts at the ideas of my fingers. Thank you and keep up the beneficial work!

  28. Louis Vuitton Replica Glasses December 6, 2011 at 5:26 am

    Really habitually I go to see this internet webpage. It incredibly greatly is pleasant to me. Thanks the author

  29. moncler sale December 16, 2011 at 11:18 am

    Hello, i think when i saw you visited my internet site well, i reached ??return the favor??.

  30. dani December 17, 2011 at 5:22 am

    Hi there, just became alert to your blog through Google, and found that it’s really informative. I’m gonna watch out for brussels. I will be grateful if you continue this in future. Many people will be benefited from your writing. Cheers!

  31. free amazon vouchers December 18, 2011 at 11:56 pm

    Hey. Very nice website!! Guy .. Excellent .. Wonderful .. I’ll bookmark your site and take the feeds also…I am satisfied to find numerous useful information here in the article. Thank you for sharing…..

  32. Jean Mackson December 23, 2011 at 1:58 pm

    Throughout this great design of things you actually receive a B- just for effort and hard work. Exactly where you confused us was first in your details. You know, it is said, the devil is in the details… And that couldn’t be more true in this article. Having said that, allow me tell you what did give good results. Your authoring can be rather engaging and this is probably the reason why I am making an effort to opine. I do not really make it a regular habit of doing that. Second, whilst I can certainly notice the leaps in logic you make, I am not confident of just how you appear to unite your ideas which in turn help to make the final result. For right now I will, no doubt yield to your issue however wish in the foreseeable future you link the dots better.

  33. click May 30, 2012 at 6:56 pm

    Although I actually like this publish, I believe there was an spelling error close to the end from the 3rd paragraph.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: