Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Some websites have variable prefixes. For example: is presented as How do I do that? I assume its a sub-directory, but can't find anything explaining how to treat it as such.

I recently set up an apache server, if the specific server software is a factor. The closest I've found is mod_rewrite, but it clearly doesn't do what I want.

Searching for help on this issue has been tricky, as I'm pretty sure "prefix" is the wrong word for what I'm describing. Aside from how to do it, what's the word for the process I'm describing?

share|improve this question

migrated from Oct 9 '12 at 15:55

This question came from our site for professional and enthusiast programmers.

I think you need to define this on the server. On Control Panel you should be able to set sun directories – Mahsa Teimourikia Oct 9 '12 at 14:09
"subdomain" is the word you're looking for there. You'll need to set up that subdomain in your DNS. – ultranaut Oct 9 '12 at 14:11

4 Answers 4

You are looking to create a subdomain of your website. You would need to define a virtual host on Apache and define a new folder for your new subdomain. You could then use mod_rewrite, or even a redirect to move the user to your subdomain when they hit

You will also need DNS entries to make the URL display correctly in visitor's browsers.

share|improve this answer

What you need is called virtual hosts, here is the link on which you can learn more about it...

It is best to go to your domain registrant panel and add there subdomain pointing with A record to IP address of your server...

Then on the server use command line to find httpd.conf:


 find / -name httpd.conf
  • most probably you will need root access rights to do find from / dir so put sudo in front of above command. Or login as root before doing it.

And there configure virtual host according to manual on the link above.

Restart apache after saving httpd.conf!

share|improve this answer

You're looking at making a subdomain. Many modern hosting providers will over this as part of their backend / control panel, so the exact answer would depend on your hosting provider.

share|improve this answer

There are two issues here. It sounds like you want to create a name based virtual host. You configure a name based virtual host in Apache.

So you would have something like:

NameVirtualHost *:80  (Note NameVirtualHost is deprecated in Apache 2.4 which I've linked above)

<VirtualHost *:80>
DocumentRoot /www/bob_11

The second issue is how you configure your DNS to recognize the name, or what you have called a prefix. The easiest way is to add a CNAME record which contains the name you want and points to the existing www name as an alias.

Your DNS should be configured like so:             CNAME                 A
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.