Note that there are some explanatory texts on larger screens.

plurals
  1. POhtaccess subdomai (part 2)
    text
    copied!<p>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.</p> <p>Ok, project wants each registered member to have a unique url (subdomain), for example user foobar will have foobar.example.com.</p> <p>After some reading i have asked my hosting company to enabled name server and web server to accept wildcard requests.</p> <p>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.</p> <p>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</p> <p>demo.example.com/gallery.php to be served by www.example.com/sub_gallery.php?user=demo</p> <p>demo.example.com/gallery.php?page=2 to be served by www.example.com/sub_gallery.php?user=demo&amp;page=2</p> <p>All pages in subdomains have the same pattern: [sub_].</p> <p>Based on the above, i have constructed some htaccess rules. But I get no good results.</p> <p>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).</p> <p>My current htaccess (at root folder) is:</p> <pre><code>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} !^([^&amp;]*&amp;)*user=[^&amp;]+ 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} !^([^&amp;]*&amp;)*user=[^&amp;]+ 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] </code></pre> <p>Can anyone see any error and provide some feedback? Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload