B
B
Blackman2011-09-12 14:18:30
Apache HTTP Server
Blackman, 2011-09-12 14:18:30

Apache2 mod_rewrite creating subdomains

Question about setting up sub-domains for Apache.

There is a dedicated server (Debian) with full access. Where do you need to register and what exactly to make sub-domains work?

You need several virtual sub-domains, like vip.domain.loc or profile.domain.loc. The redirect should be to the domain.loc root site folder.

There are actually several questions ...
Do I need to register sub-domains in the /etc/hosts file and in the settings file (VirtualHost) in the sites-available directory? What should be the rules for forwarding?

I will be glad for any answers.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
@
@antoo, 2011-09-12
_


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain.com
RewriteCond %{HTTP_HOST} ([^.]+)\.domain.com
RewriteRule ^(.*)$ /user.php?username=%1

username.domain.com -> domain.com/user.php?user=username

I
Ivan Garbuz, 2011-09-12
@garbuzivan

ServerAlias ​​*.host.com
I hope you can configure htaccess?
PS If anything, write in a personal - I'll help you that it's not clear!

A
Anatoly, 2011-09-12
@taliban

The rewrite mod has nothing to do with it, just set up virtual domains (subdomains in your case) that link to where you need to.

O
Oleg Batishchev, 2011-09-12
@z0rg

setting up conf for apache, you don't even need a rewrite
create virtual servers, specify the necessary paths and domain names in the ServerName directive
if you want to use one multi-domain engine, then you just need to refer everything to it and cms itself will resolve the domains
So what do you want in the end ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question