Ok after my previous post, i have made some progress, yet still i need help. For those that read this post first, here is a synopsis.
Ok, project wants each registered member to have a unique url (subdomain), for example user foobar will have foobar.example.com.
After some reading i have asked my hosting company to enabled name server and web server to accept wildcard requests.
This part of the project i think i have managed to solved/create. Now i need to find a way to create subpages in subdomains.
Purpose is demo.example.com and demo.example.com/ and demo.example.com/index.php to be served by www.example.com/sub_index.php?user=demo
demo.example.com/gallery.php to be served by www.example.com/sub_gallery.php?user=demo
demo.example.com/gallery.php?page=2 to be served by www.example.com/sub_gallery.php?user=demo&page=2
All pages in subdomains have the same pattern: [sub_].
Based on the above, i have constructed some htaccess rules. But I get no good results.
Actually: requests made to demo.example.com work perfect requests made to demo.example.com/ OR demo.example.com/index.php show me the example.com/index.php requests to demo.example.com/gallery.php throws 404 error (although page sub_gallery.php is in root folder).
My current htaccess (at root folder) is:
Options +FollowSymLinks
RewriteEngine on
RewriteOptions inherit
RewriteBase /
#rewrite example.com to www.example.com
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.htm([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.example.com/$1 [R=301,L]
###########################
## subdomains
###########################
#index
RewriteCond %{QUERY_STRING} !^([^&]*&)*user=[^&]+
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.example.com
RewriteRule ^$ /sub_index.php?user=%1 [L]
#other pages
RewriteCond %{QUERY_STRING} !^([^&]*&)*user=[^&]+
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.example.com
RewriteRule ^/other_page.php$ /sub_other_page.php?user=%1 [QSA,L]
Can anyone see any error and provide some feedback? Thank you