Forum Moderators: phranque
This is what I'm trying to do;
I'm trying to get (for example) http://subdomain1.example.com/ to silently rewrite to http://example.com/subdomain1/ folder using .htaccess / Mod_rewrite.
I've currently got wildcard sub-domains turned on, and if I go to http://anythingcanbetypedhere.example.com it directs to my main index.html page, so I know for fact that wildcard sub-domains are working.
The whole point to this is I'm starting a free forum hosting community and I want my users to have sub-domains, rather than folder paths... and I don't want to hard-code each sub-domain into .htaccess every time someone signs up.
I'd also like it if the Mod_rewrite could keep the subdomain in the address bar once it has redirected to the folder.. for example (on the main page of the folder it would look like this in the URL bar); http://subdomain1.example.com/index.php
Thanks in advance to anyone who can help me out with this..
The code I'm trying to rewrite is as follows;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([-_a-zA-Z0-9]{0,30})$ $1/ [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([-_a-zA-Z0-9]{0,30})/(.*)$ phpBB3/$2?access_name=$1 [QSA,L]
The code above was written automatically by the multi-hosting script I use.. without that code, I can't access any folders within the script, even when manually typing in the url to the folder..
Again, thank you for any help you can provide.. and please, try not to get too technical as I'm still learning apache jargon :$
[edited by: jdMorgan at 2:47 pm (utc) on Jan. 3, 2008]
[edit reason] example.com [/edit]
Also be aware that your first rule, which is apparently intended to avoid duplicate content by redirecting 'virtual' URLs to add a trailing slash if none is present, is self-defeating, in that it generates a 302-Found redirect. Therefore, search engines will not update their databases to use this new URL, but will continue to use the originally-requested slashless URLs. Change the 'R' flag to 'R=301' to avoid this problem.
Jim
[edited by: jdMorgan at 2:48 pm (utc) on Jan. 3, 2008]
I have no idea how to do this correctly.. otherwise I wouldn't have posted.
The rules I posted before need to be included, otherwise my script doesn't work properly.
What I was requesting was for someone to help me create an htaccess file that would automatically redirect subdomains to folders of the same name on the server.. so;
http://testboard.example.com would bring the user to http://www.example.com/testboard .. but would, preferably, keep the URL; http://testboard.example.com
[edited by: jdMorgan at 3:36 am (utc) on Jan. 5, 2008]
[edit reason] example.com [/edit]