Beste mensen,

Na wat zoeken in het forum ben ik niets wijzer geworden. De bedoeling is dat ik via .htaccess ipv link http://www.website.nl/sites/"gebruikersnaam";

ook in kan tikken http://"gebruikersnaam".website.nl


"gebruikersnaam" is hierbij 1 van de XXXX gebruikersnamen..

Bij voorbaat dank en Mvg,
Marvin



edit: ik heb nu dit en dit werkt niet..

RewriteEngine On 
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^(.+)\.website\.nl
RewriteCond %{1} !^www
RewriteRule ^$ http://www.website.nl/sites/%1

Jawel.. alles wat ik hier vind is vastenaam.site.nl -> site.nl/vastenaam

en ik heb juist variabele.site.nl -> site.nl/sites/variabele..

Dit is gewoon een virtual host...
@Martijn
Kun je dat toelichten? of heb je een oplossing?
Een virtual host kun je een variabel maken, dus:

[hierkanvanallesstaan].domein.nl

Deze gaat dan naar een vaste map.

Je zou ook meerdere virtual hosts kunnen maken met een vast subdomein.

Hierover kun je genoeg vinden, in de apache documentatie.

Marvin schreef op 21.12.2007 22:59
Jawel.. alles wat ik hier vind is vastenaam.site.nl -> site.nl/vastenaam

en ik heb juist variabele.site.nl -> site.nl/sites/variabele..


wel pas dan aan dat het zo wordt:

vastenaam.site.nl -> site.nl/sites/vastenaam
of
vastenaam.site.nl -> site.nl/sites.php?user=vastenaam

webmasterworld
I asked about httpd.conf and .htaccess because the mod_rewrite syntax differs slightly between the two environments.
The main problem with your combined code is that ".*" matches anything, so the first rule will always be invoked, and the second rule will never be invoked. Requests for images, CSS files, etc. will also be rewritten to index.php. But there is more to it than that...

Do you have a user named "www"? Probably not, so what should happen if someone accesses your site using www.mydomain.com? Make sure you do not allow a user to create a user-subdomain called "www" -- It could disable a large part of your site.

What if someone requests www.subdomain.mydomain.com or subdomain.www.mydomain.com?

You will need to come up with a complete plan that includes all possibilities.

The following demonstrates the use of RewriteConds and specific patterns (instead of ".*") to do what I think you said you want to do:

# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
#
# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.mydomain\.com
RewriteRule (.*) http://%1.mydomain.com/$1 [R=301,L]
#
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.mydomain\.com
RewriteRule (.*) http://%1.mydomain.com/$1 [R=301,L]
#
# If www domain requested, rewrite html page requests to show.php with query string
RewriteCond %{REQUEST_URI} !^/show\.php
RewriteCond %{HTTP_HOST} ^www\.mydomain.com
RewriteRule ^([^.]+)\.html /show.php?page=$1 [L]
#
# If subdomain requested, rewrite subdomain and html page requests to index.php with query string
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^([^.]+)\.html /index.php?user=%1&page=$1 [L]
#
# If www domain requested, rewrite home page requests to show.php with query string page = "home"
RewriteCond %{REQUEST_URI} !^/show\.php
RewriteCond %{HTTP_HOST} ^www\.mydomain.com
RewriteRule ^$ /show.php?page=home [L]
#
# If subdomain requested, rewrite home page requests to index.php with query string user=subdomain & page="home"
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^$ /index.php?user=%1&page=home [L]

Any requests for files that do not end in ".html" will not be rewritten to the scripts, except for home page requests in the form "www.mydomain.com/" or "subdomain.mydomain.com/" where the "filename" is blank.

You showed two php files, "show.php" and "index/php" -- I have kept them separate in the code above, but you should be able to correct the code if you really use only "index.php".

This may or may not cover all possibilities on your site -- but you will have to. Study the resources cited in our charter until you understand how this code works, and then modify it to suit your needs. This code is untested.

Jim
@Hipska
ja dat snap ik.. ik post hier die vraag omdat het mij niet lukt.. Als ik het kon had ik dit topic niet geopend..

edit:
@Hipska
ja dat stuk kan ik denk ik wat mee.. bedankt :D
*bump*

wederom niet gelukt.. snap niet waarom mijn stukje uit de start post niet werkt..
Ja dit is erg handig, en wilde ik ook gebruiken. Je zou hyves kunnen mailen, maar ik denk niet dat zij dat gaan geven :')

Reageren