Forum Moderators: mack
i created new subdomains for my website (all the old ones work fine with the 301 redirect i manually set up using the htaccess file - i set them up so if you type "example.com/folder1" it will redirect to "folder1.example.com")
anyway with all the new subdomains i set up...after i modified the htaccess file to include these new subdomains i get error messages when i try to go to the new subdomains. the error says something like
"too many redirects occurred trying to open "folder1.example.com" - this may occur if you open a page that is redirected to open another page which is then redirected to open the original page"
my boyfriend called and tried to figure it out and he was on the phone screaming foul words at them for hours and then he finally found someone who knew what was going on and i think the verdict is "you're screwed". i guess there are automatic redirects that godaddy sticks in but they dont seem to work, and when you do your own the RIGHT way using htaccess stuff it says "you are doing something that has already been done"
anyway...moral to the story i guess is avoid cheap hosting
To avoid it, you can use a RewriteCond to see if the request for example.com/folder1 is occurring as a result of a client request, or as a result of the internal rewrite.
It is also necessary to check to be sure that you avoid rewriting example.com/folder1 to example.com/folder1/folder1... ad infinitum.
Here's an example of one way to accomplish this in example.com/.htaccess:
# Externally redirect (only) client requests for example.com/<subdomain> to subdomain.example.com/
# (This will not apply if the request is the result of the following internal rewrite)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(folder1¦folder2¦folder3)
RewriteRule ^[^/]+(.*)$ http://%1.example.com$1 [R=301,L]
#
# Internally rewrite <subdomain>.example.com/<URL-path> to /<subdomain>/<file-path>, but
# only if we haven't already done it, and exclude the "www" subdomain from this rewrite.
RewriteCond %{ENV:RewriteDone} !^Yes$
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1/$1 [E=RewriteDone:Yes,L]
This also assumes that you have wild-card subdomains enabled in DNS and in conf.d, and that no "control panel" functions have been used to generate any subdomain-related code in the conf.d file that interferes with this code.
Jim
if it's ok here is a screencap of the htaccess file that works EXCEPT for the very last line. in other words, all the stuff listed here works correctly as far as subdomains getting redirected but the very last line that says /aj-cook/ is the only one that does not work. again the only difference between the /aj-cook/ subdomain and the others is that all the others were created more than a year ago and the aj-cook subdomain was created yesterday with a different setup within the hosting preferences.
screencap: <snip>
of course their tech support has no idea :0P
:0)
[edited by: engine at 7:56 am (utc) on July 17, 2007]
[edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]