Sto usando Cakephp framework 2.2.2.URL Riscrivi creare sottodominio in cakephp
Desidero creare un URL personalizzato per l'utente. Ad esempio, se un utente inserisce username = pragnesh, poi si può accedere al mio sito come: http://pragnesh.mylocalhost.com, come nel blinksale.com
mio URL: http://mylocalhost.com/test/users/front_home
voglio accedervi in: http://test.mylocalhost.com/users/front_home
mio URL: http://mylocalhost.com/test/setting/pages
si può accedere a: http://test.mylocalhost.com/setting/pages
qualsiasi URL: http://mylocalhost.com/test/xxxxx/xxxxx
si può accedere a: http://test.mylocalhost.com/xxxxx/xxxxx
O
URL: http://mylocalhost.com/users/front_home?site=test
voglio accedervi in: http://test.mylocalhost.com/users/front_home
mio URL: http://mylocalhost.com/setting/pages?site=test
si può accedere a: http://test.mylocalhost.com/setting/pages
qualsiasi URL: http://mylocalhost.com/xxxxx/xxxxx?site=test
si può accedere a: http://test.mylocalhost.com/xxxxx/xxxxx
La mia domanda può essere possibile duplicato di My cakephp 2.2 site not working on subdomain ma non c'è risposta postato.
ho cercato qui di seguito il codice in app \ webroot.htaccess
RewriteCond %{QUERY_STRING} !^([^&]*&)*site=[^&]+
RewriteCond %{HTTP_HOST} !^www\.mylocalhost.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.mylocalhost.com
RewriteRule ^([^\.]*).php$ /$1.php?user=%1 [QSA,L,R]
# capture first part of host name
RewriteCond %{HTTP_HOST} ^([^.]+)\.mylocalhost\.com$ [NC]
# make sure site= query parameter isn't there
RewriteCond %{QUERY_STRING} !(^|&)site= [NC]
# rewrite to current URI?site=backererence #1 from host name
RewriteRule^%{REQUEST_URI}?site=%1 [L,QSA]
\ ma entrambi non funziona per me.
la mia radice.file di htaccss è
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
\ app.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
\ app \ webroot.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Virtual Host in httpd.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/bsale"
ServerName mylocalhost.com
ServerAlias *.mylocalhost.com
<Directory "C:/xampp/htdocs/bsale">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
HOST FILE
127.0.0.1 mylocalhost.com
127.0.0.1 *.mylocalhost.com
Che cos'è DocumentRoot del sottodominio di test? Puoi anche inserire la voce 'VirtualHost' del sottodominio' test' da Apache config? – anubhava
root del documento è mylocalhost, non ho accesso ai file di hosting –
'DocumentRoot' deve essere un percorso completo del file system ed è necessario conoscere esattamente' DocumentRoot' per il dominio principale e il dominio secondario 'test'. – anubhava