1

I'm sure there is documentation for how to do this, but I don't know what it's called so I don't even know how to start searching.

On my webserver, example.com, i have a site called site. It's accessed by going to example.com/site.

I want it instead to be site.example.com.

Can someone point me to apache documentation to enable this?

2 Answers 2

1

I think you need to use virtual host. Edit the file called .../apache/conf/extra/httpd-vhosts.conf and add this line:

<VirtualHost *:80>
    DocumentRoot "[PATH-TO-APACHE]/Apache2.2/htdocs/tema"
    ServerName site.example.com
</VirtualHost>

Of course you need also to enable virtual hosts on apache editing the httpd.conf file.

2
  • Thanks, do I only need to enable virtual hosts by creating virtual.conf with the content NameVirtualHost * under apache2/conf.d?
    – Bill
    Jul 16, 2012 at 22:34
  • @B.VB. You can enable it removing the '#' before this line Include conf/extra/httpd-vhosts.conf in the httpd.conf . Anyway you can find a lot of stuff searching for "Enable virtual hosts on [YOUR-OPERATING-SYSTEM]" Jul 17, 2012 at 0:10
0

Are you sure you want to rewrite or redirect people from the subfolder to a subdomain? Why not create a virtual host / subdomain then do 301 from the old subfolder to the subdomain?

This is a good tutorial on creating subdomains

http://thinkingnectar.com/2008/getting-ubuntu-to-work-creating-subdomain-in-localhost/

2
  • No i don't want to redirect from a subfolder to a subdomain.. In fact I dont want a subdomain at all. I want site.example.com to reference example.com/site (as I plan to have other sites on this host, and don't want to have them all be example.com/site{a, b, c}
    – Bill
    Jul 16, 2012 at 19:39
  • What do you mean by site.example.com reference example.com/site? Do you mean have them both display the same content?
    – Anagio
    Jul 16, 2012 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.