php - Cannot figure out this wildcard subdomain mishap -


i've been trying accomplish hours , reason not want work.

all want username.domain.com internally go domain.com/users/username

i set-up dns wildcard subdomain points towards public_html/wild folder , placed index.html file in there , seems work well.

the problem when use .htaccess file:

rewritecond %{http_host} !^www\.domain\.com$ [nc] rewritecond %{http_host} ^(www\.)?([a-z0-9-]+)\.domain\.com$ [nc] rewriterule !^index\.php($|/) index.php/users/%2%{request_uri} [pt,l] 

it shows 404 page not found error. checked logs , says still looks in /wild folder, script 1 level in public_html folder.

how can fix problem? thank you!

you you've pointed wildcard subdomain public_html/wild, means when requests http://user.domain.com/ / request mapped public_html/wild. means request wildcard subdomain never able mapped in parent directory public_html (that's why it's called document root).

one of things can point document root of wildcard subdomains same place main domain, place index.php is. if you've got content main domain don't want mixed subdomains or vice versa, try using p flag utilizes mod_proxy , creates reverse proxy:

rewritecond %{http_host} !^www\.domain\.com$ [nc] rewritecond %{http_host} ^(www\.)?([a-z0-9-]+)\.domain\.com$ [nc] rewriterule !^index\.php($|/) http://www.domain.com/index.php/users/%2%{request_uri} [p,l] 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -