Forum Moderators: phranque

Message Too Old, No Replies

Need Suggestions for Script Used to Redirect Subdomains to Subfolders

         

ambaxter

3:38 pm on Jan 25, 2010 (gmt 0)

10+ Year Member



I used the following code in my htaccess, as published on this thread [webmasterworld.com ] a while ago:

RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ([a-z0-9][-a-z0-9]+)\.example\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]

This script works beautifully. However, I am using a content management system that has a feature where it will build a sitemap (virtually) from all pages. But it fails when this redirect method is employed.

Does anyone know why that might be?

[edited by: jdMorgan at 4:01 pm (utc) on Jan. 25, 2010]
[edit reason] example.com [/edit]

ambaxter

7:43 pm on Jan 25, 2010 (gmt 0)

10+ Year Member



I read on a blog that uses this script that the "environment variable is set to the web root and not the project root directory" and I figured it out.

I had to make my CMS' subdomain sites refer to its config file in the ROOT directory instead of a copy that lives in the subdirectory.

Back to working perfectly again. Thanks, @jdMorgan for all the amazing work you've posted here.