Projemde ben yani, bir subdomain yapmak zorunda
o kayıt sırasında kullanıcı adı XXX ise, bir alt etki alanı XXX.example.com gibi oluşturulacaktır
bunu nasıl?
Ben komut dosyası için php kullanmak olacaktır.
selamlar
Tarique
I found a script that seems to do exactly that, create a subdomain on your server on demand. It probably needs a little bit of tweaking for it to work on your particular control panel, but the review are quite positive as far as I can tell.
Have you considered using htaccess and url rewriting? Found this code that may help you:
# Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
#
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.example\.com(:80)?<>/([^/]*) [NC]
# Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) /%1/$1 [L]
Sadece bir joker DNS etki alanı ve vhostu kullanmak, daha sonra PHP kodu herhangi bir etki alanı belirli davranışları haritası - Sürece bu SSL olmayan siteler için olduğu gibi, o kadar kolay yolu rahatsız değildir. Eğer onun çok daha karmaşık SSL siteleri ihtiyacınız varsa - ve woldcard certs çok pahalı olabilir - ayrı bir IP adresi / her sertifika için bağlantı noktası olması gerekir.
Eğer hosting paketi çeşit kurmak isteyen iseniz o zaman onun biraz daha yer - Bu konuda gitmek nasıl kullandığınız hangi web sunucusu ve DNS sunucusu bağlıdır.
Assuming (again no SSL) with Apache on Unix/POSIX/Linux and bind, then, again I'd go with a wildcard DNS entry, then: 1) create a base dir for the website, optionally populate this with a default set of files 2) add a vhost definition in its own file in /etc/httpd/conf.d named as XXX.conf 3) send a kill -HUP to the HTTPD process (causes it to read the new config files without having to do a full restart).
Sen kesinlikle root ayrıcalıkları vermek istemiyorum - Unutulmaması gereken bir şey, gerçekten kendi yapılandırma dosyalarını httpd süreci doğrudan yazma erişimine izin gerektiğidir. A güvenli çözüm bir argüman olarak adını kullanarak o setuid ve HTTPD işlemi tarafından işletilen komut onu çağırmak bu gerçekleştirmek için bir CLI komut dosyası oluşturmak olacaktır.
C.
en iyi yolu DNS sunucu bir joker kullanmak için:
www.example.com. IN A 1.2.3.4
*.example.com. IN A 1.2.3.4
Bu arada, hiçbir alt etki alanı oluşturulmuş olması gerekir: Bütün varsayılan olarak aynı IP işaret ediyor.
PHP kodu, sadece ["ANA"] $ _SERVER almak ve yumruk parçası olsun adres:
$hostParts=explode('.',$_SERVER["HTTP_HOST"]);
$user=$hostParts[0]
Since you will make sub-domains when an user registers. Try this as .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^.htaccess$ - [f]
RewriteCond %{HTTP_HOST}!^www.domain.com
RewriteCond %{HTTP_HOST} ^([^.]+).domain.com
RewriteRule ^$(.*) /$1/%1 [L]
make a function of a controller which will take the value of sub-domain and display what necessary. like::
public function show ($domain)
{
**.**..*..**.** Your code goes here
}
Bir kullanıcı bu deneyin ne zaman xxx.domain.com/controller/show bu olacak domain.com/controller/show/xxx. Eğer xxx.domain.com olmak istiyorsanız istediğiniz gibi domain.com/controller/show/xxx sadece htaccess dosyasını düzenlemek.