i have my site set up like this:
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.com [NC]
RewriteRule ^/?$ /user/profile.php?name=%1 [L]
what this does is if user visits: test.example.com
, it will show contents of folder: example.com/user/profile.php?name=test
. if someone goes to lol.example.com
, it will show page: example.com/user/profile.php?name=lol
Question 1:
right now, I have a problem with it. if i go to test.example.com/login
, it will show my domain root file. how can i make it so that it will show things from /user folder? for example: test.example.com/login
will show example.com/user/login
and test.example.com/register
will show example.com/user/register
?
Question 2: SOLVED
right now if i log in on the subdomain, the session cookie (PHP) is only set for the subdomain. how can i make the cookies work for the whole site with (example.com) domain?
thanks
UPDATE: for example: test.example.com/pathtofile
should get the contents of example.com/user/pathtofile
. "pathtofile" should be dynamic. i just want the path to look in the folder /user, not the root folder.
Try something like this
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.com [NC]
RewriteRule ^/?$ /user/profile.php?name=%1 [L]
RewriteRule (.*) /user/$1 [L]