[Apache] *.domein.nl -> www.domein.nl/*

Pagina: 1
Acties:

  • amphora
  • Registratie: December 1999
  • Laatst online: 21:30

amphora

Websites & Fotografie

Topicstarter
Ik wil dus via mod rewrite alle subdomeinen automatisch laten doorsturen naar een subdirectory op de www site. Het subdomein moet wel als url in de browser blijven staan.

test.domein.nl -> www.domein.nl/test
hop.domein.nl -> www.domein.nl/hop
test.domein.nl/hoi.html -> www.domein.nl/test/hoi.html
etc...

Ik wil niet voor ieder subdomein apart een rewriterule gaan maken, is dat mogelijk? Mits DNS record voor dat subdomein bestaat natuurlijk. Wildcard DNS bijvoorbeeld.

Ik heb op GoT al wat zitten zoeken maar dat waren PHP oplossingen of per subdomein instellen in httpd.conf, dat wil ik dus niet.

nickdekruijk.nl Websites & Fotografie


  • GGS_VR6
  • Registratie: Juli 2001
  • Niet online

GGS_VR6

Oranje!

Dat kan je het beste met virtual hosts gaan werken

code:
1
2
3
4
5
6
7
8
9
10
<VirtualHost *> 
ServerName domein.jeserver.nl 
DocumentRoot C:\www1\piet\domein\domein.jeserver.nl 
<Directory "C:\www1\piet\domein\domein.jeserver.nl"> 
Options Indexes FollowSymlinks MultiViews 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 
</VirtualHost>


Klap dit maar eens in je httpd.conf

T.net ID. Bekijk het maar es eem..
‹(◕‿◕)›


  • Wilke
  • Registratie: December 2000
  • Laatst online: 22:37
Edit: Oeps niet helemaal goed gelezen wat het probleem is...maar het is denk ik wel uit te vinden mbv de Apache FAQ:

Apache FAQ

  • GGS_VR6
  • Registratie: Juli 2001
  • Niet online

GGS_VR6

Oranje!

en in PHP

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?    
$adres=" ".getenv("HTTP_HOST");    

if (strpos($adres,"subdnaam.domein.nl")>0){    
                $koppeling = "mapnaam";    
                            }    
if (strpos($adres,"subdnaam.domein.nl")>0){    
                $koppeling = "mapnaam";    
                             }    
if (strpos($adres,"subdnaam.domein.nl")>0){    
                $koppeling = "mapnaam";    
                              }    
if (strpos($adres,"subdnaam.domein.nl")>0){    
                $koppeling = "mapnaam";    
                                                }    
if (!$koppeling){    
        $koppeling="/index.php";    
        }    
Header("Location: $koppeling");    
?>


Deze code zet je in een bestand wat index.php heet

T.net ID. Bekijk het maar es eem..
‹(◕‿◕)›


  • luc
  • Registratie: Maart 2000
  • Niet online

luc

Wat jij zoekt is mod_vhost_alias. Even apache compilen met deze module er in en de manual lezen..

  • dwa
  • Registratie: Augustus 2002
  • Niet online

dwa

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.domein.nl$
RewriteCond %{REQUEST_URI} !^/sub/

in je .htaccess zetten
Pagina: 1