homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

This 32 message thread spans 2 pages: < < 32 ( 1 [2]     
Subdomain to domain re-writing
subdomain rewriting

5+ Year Member

Msg#: 4191662 posted 10:28 pm on Aug 24, 2010 (gmt 0)

how do i re-write :

[subdomain.domain.com...] to [domain.com...]



WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4191662 posted 2:02 am on Aug 31, 2010 (gmt 0)

Then I'd suggest that you comment out all lines of the first rule until you have well-defined lists of the subdomains which you do and do not wish to resolve to subdirectories, and conversely, of all subdirectories which do and which do not represent the "file storage areas" for your subdomains. You mentioned "features", "about-us", and "signup" early-on, but did not mention "/images" or "/administrator" until the 29th post in this thread...

Please refer to the resources listed in our Apache Forum Charter, and to the description in that Charter of the purpose of this forum. Once you have studied those references and compared what's in them to the commented code posted here, you should be able to modify the code to do exactly what you want.



5+ Year Member

Msg#: 4191662 posted 2:49 am on Nov 2, 2010 (gmt 0)

Hi Jd Morgan,

I have been using : #################BEGIN RULES ON LIVE SITE
# Externally redirect direct client requests for subdomain-subdirectory URLs which
# resolve to existing subdirectories back to canonical subdomain root URLs
RewriteCond $1 !^(features|terms-of-service|about-us|signup|media|includes|modules|cgi-bin|templates|xmlrpc|language|libraries|plugins|administrator|component|images)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([a-z0-9\-]+)/[^\ ]*\ HTTP/
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^([a-z0-9\-]+)/(.*)$ [$1.example.com...] [R=301,L]
# Externally redirect requests for /features, /about-us, /signup, /images in subdomains to main domain
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.example\.com
RewriteCond %1 !^www\.
RewriteRule ^(features|about-us|terms-of-service|signup|component|includes|media|cgi-bin|templates|xmlrpc|language|modules|libraries|plugins|administrator|images(/.*))$ http://example.com/$1 [R=301,L]
# Externally redirect all www hostnames to non-www hostnames
RewriteCond %{HTTP_HOST} ^(([a-z0-9\-]+\.)*)www\.(([a-z0-9\-]+\.)*)example\.com
RewriteRule ^(.*)$ [%1%3example.com...] [R=301,L]

I notice google is indexing my subdomains with the /index.php even though i have a rule in robots.txt to block /index.php in the subdomain and main domain.

Is there a rule that can check if there is a subdomain redirect to the subdomain such as [one.example.com...] redirects to [one.example.com...] only

I had this rule to redirect index.php to main domain

#RewriteCond %{THE_REQUEST} ^.*/index.php
#RewriteRule ^(.*)index.php$ http://example.com/$1 [R=301,L]

But what i need to know is to run the rule once its in a subdomain and also not redirect to something that would prevent me from going into the backend

The index.php rewrite rule above prevents me from using:

http://example.com/admin/index.php because it would redirect to

This 32 message thread spans 2 pages: < < 32 ( 1 [2]
Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved