php - URL Rewrite create subdomain in cakephp -



php - URL Rewrite create subdomain in cakephp -

i using cakephp framework 2.2.2.

i want create personalized url user. example, if user enters username=pragnesh, can access site like: http://pragnesh.mylocalhost.com, same in blinksale.com

my url: http://mylocalhost.com/test/users/front_home

i want access at: http://test.mylocalhost.com/users/front_home

my url: http://mylocalhost.com/test/setting/pages can accessed at: http://test.mylocalhost.com/setting/pages

any url: http://mylocalhost.com/test/xxxxx/xxxxx can accessed @ : http://test.mylocalhost.com/xxxxx/xxxxx

or

url: http://mylocalhost.com/users/front_home?site=test

i want access at: http://test.mylocalhost.com/users/front_home

my url: http://mylocalhost.com/setting/pages?site=test can accessed at: http://test.mylocalhost.com/setting/pages

any url: http://mylocalhost.com/xxxxx/xxxxx?site=test can accessed at: http://test.mylocalhost.com/xxxxx/xxxxx

my question may possible duplicate of my cakephp 2.2 site not working on subdomain there no reply posted.

i have tried below code in \app\webroot.htaccess

htaccess subdomai (part 2)

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]

url rewrite subdomain

# capture first part of host name rewritecond %{http_host} ^([^.]+)\.mylocalhost\.com$ [nc] # create sure site= query parameter isn't there rewritecond %{query_string} !(^|&)site= [nc] # rewrite current uri?site=backererence #1 host name rewriterule ^ %{request_uri}?site=%1 [l,qsa]

but both not working me.

my root .htaccss file is

<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 </directory> </virtualhost>

host file

127.0.0.1 mylocalhost.com 127.0.0.1 *.mylocalhost.com

you can leave .htaccess in default cakephp/.htaccess cakephp/app/.htaccess cakephp/app/webroot/.htaccess

you need virtual host have pointing @ app.

what need @ app/config/routes.php

take @ line says:

cakeplugin::routes();

so, before moment can need (with routes). lets imagine user johndoe has http://johndoe.yourapp.com/

get subdomain url, this:

array_shift((explode(".",'subdomain.my.com')));

using:

$_server['http_host'] router::connect('/users/front_home', array('controller' => 'users', 'action' => 'front_home', $yoursubdomain));

or leave router lone , observe subdomain in appcontroller, , utilize anywhere in app.

php .htaccess cakephp mod-rewrite cakephp-2.2

Comments

Popular posts from this blog

javascript - I need to update the text of a paragraph by inline edit -

javascript - THREE.js reposition vertices for RingGeometry -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -