Forum Moderators: phranque
Basic Assumptions:
- It is available to be using wildcard dns setup, i.e. have access to configure Vhost "Server Alias *" in apache in httpd.conf (i.e. mod_rewrite functions are fully usable for practically any desired url re-writing via htaccess.
- We wish to be using SubDomains for the purposes of shortening URLs, and making webzones navigation unique and distinctive, and wish to have it work in harmony with seo general requirements.
Scenario's (essentially 2 I think):
Prelim-Notes:
1) I will be using the example of setting up a forum on a website having, say, 2 basic functions.
a) to be presenting basic website content pages for 'whatever-subject', and
b) to be providing a separate forum for 'whatever-other' subject.
- There may/will even be other forum(s) setup for 'whatever-additional-other' subject(s).
====================================
Scenario1: A Real SubDomain
Set up a forum on a domain... installed into a subfolder named "forum". So the actual location url is something like
- www.domain.com/forum - ,
Create a 'Real' SubDomain by adding a DNS Zone for "forum" ,
and then script .htaccess accordingly to be mod_rewriting the pathway url to appear as the 'short url' (forum.domain.com/)
and also using 301 redirects
Scenario2: A Virtual SubDomain
Set up a forum on a domain... installed into a subfolder named "forum". Location same a Scenario1
Do Not Create a Real SubDomain by adding any DNS Zone for it.
Simply script .htaccess accordingly to be rewriting the pathway url to appear as a short url (forum.domain.com/),
and also using 301 redirects
(I hope I have the correct understandings here for the most basic ideas being presented.)
I can do both of these scenarios, but I do not know if one way is better than another with regard to seo duplication concerns.
------------
**There are two other scenarios to consider (may not matter, but better to mention it now just in case):
Scenario1B: A Real SubDomain, but install foldername is different than SubDomain Name
So, for instance, You create DNS Zone for "myforum", and the actual forum is
installed into - www.domain.com/harrysforum -
Simply script .htaccess accordingly to be rewriting the pathway url to appear as the short url (myforum.domain.com/),
and also using 301 redirects
Scenario2B: A Virtual SubDomain, but install folder is different than SubDomain Name
(This seems a least likely scenario, but...) So, for instance, same thing as Scenario2 except the virtual subdomain name is different than the installation folder ...blah, blah, blah... I think one should easily get the picture(?).
=====================================
QUESTIONS: (Sorry if any of this seems overly-acedemic, or if I am not quite using terminology representing an accurate understanding, ...I am simply having challenges sorting out the proper understandings to all this...)
- Does seo consider Scenario1 as generating duplicating content? (i.e. page rank penalty potential exists?) If so, why would anyone use this method then?
- Is there any seo benefit (to potential page ranking) to using Scenario2? (I think there is no potential penalty value there, please confirm this is the correct understanding.)
- And how do the 1B and 2B scenarios potentially weigh in.
- As well, if there's something I am presuming to be doing that is obviously -stupid-, please feel free to enlighten me!
=========================================
I look forward to member responses.
Cheers,
TwoHawks
Any properly-configured subdomain-to-server-filespace mapping method will be utterly undetectable by users or search engine spiders, so there are no SEO concerns.
With that confusing "Scenario2" element present, I can't see how to answer in more detail.
Jim
1) -----------------------------
Your "Scenario2: A Virtual SubDomain" setup isn't likely to work. If you want the subdomain to resolve to your server, then setting up DNS is not optional.
Any properly-configured subdomain-to-server-filespace mapping method will be utterly undetectable by users or search engine spiders, so there are no SEO concerns.
With that confusing "Scenario2" element present, I can't see how to answer in more detail.
Maybe this will help ( he said nervously as he watched the 'apache'-samuri, jd, slightly unsheith his sword in consternating vigilant anticipation)
...whew '¦^0... ....I will provide examples of 2a and 2b that I am working out, - (I have these all working, or at least seemingly so - I mean I test them and the results are what I expect to see [he said gleefully], but maybe I am misunderstanding something about the actual server handling or other somethings(?)...
Maybe you will point out that there is irrelevant or useless logic here (or worse), I do not know.
I look forward to your, and anyone elses, response.
Below is the 'code worksheet' for scenarios 2a+b.
Thank you for taking the time, and I do so apreciate this forum.
Cheers,
TwoHawks
PS: If its too long I can break this up into separate posts, or you can.)
==============================================================
2A=============================================================
Folllowing is an example of a "Scenario 2a". Pay particular attention to #3 and #4 below
- A forum is installed at - domain.com/testforum -
- Users will be "directed" to "real" subdomain - testdirect.domain.com -
...'real' meaning there is a DNS "A" rule created for 'testdirect2' pointing to the domain IP
#### Begin .htaccess code in .htaccess file located in the root dir - (with much credit to posters here, and other places, i.e., I am not the regx master #############
###############################################################
#### Some people need these Options settings, some do not
# Options +FollowSymLinks -MultiViews
#### Turn the ReWrite Engine On
RewriteEngine On
#1 ***********************************
#### REDIRECT (adding prefix www) IF NO SUB-DOMAIN####
RewriteCond %{HTTP_HOST} ^([^.]+)\.([^.]+)$ [NC]
RewriteRule ^(.*)$ [%1.%2...] [R=301,L]
#2 ***********************************
##### Remove "www." from any subdomain requests####
##### (Same rule will work for all subdomains)####
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.com [NC]
RewriteRule (.*) [%1.domain.com...] [R=301,L]
#### ========================================================
##### Now, the Scenario 2a Relevant Code #############
#3 ***********************************
#### This is a DNS Assigned Folder###
#### Calls to TESTDIRECT.DOM.COM = contents /TESTFORUM####
RewriteCond %{REQUEST_URI}!^/testforum/.*
RewriteCond %{HTTP_HOST} testdirect\.domain\.com [NC]
RewriteRule (.*) /testforum/$1 [L]
#4 ***********************************
#### Non-servr Calls to /TESTDIRECT = TESTDIRECT.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testdirect/
RewriteRule ^testdirect/(.*) [testdirect.domain.com...] [R=301,L]
#
#### Non-servr Calls to /TESTFORUM = TESTDIRECT.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testforum/
RewriteRule ^testforum/(.*) [testdirect.domain.com...] [R=301,L]
############## END ##################
The foregoing 2A Scenario allows the use of all the following urls,
which will are all rewritten to appear to the user to be resolving to
- testdirect.domain.com - ...which is the url that gets passed out.
Also to note, if php is being used, no additional php scripting is required!
LINK1 = testdirect.domain.com (of course)
LINK2 = www.testdirect.domain.com
LINK3 = domain.com/testdirect
LINK4 = www.domain.com/testdirect
LINK5 = domain.com/testforum
LINK6 = www.domain.com/testforum
...all roads appear to lead, and/or actually lead, to one...
------------------------------------------------------------------
I did not include addressing the following potential urls because of they seem to me to be the least likely concern, but I may do it later...
LINK9 = testforum.domain.com (not addressed in the above code [yet])
LINK10 = www.testforum.domain.com (not addressed in the above code [yet])
==================================================
==================================================
Okay, then for scenario 2b, which...
- A forum is installed at - domain.com/testforum2 -
- Users will be "directed" to "virtual" subdomain - testdirect2.domain.com -
...virtual meaning there is no DNS rule created for 'testdirect2'
Simply replace #3 and #4 with
#3 ***********************************
#### This is a Non-DNS Assigned Folder####
#### Calls to TESTDIRECT2.DOM.COM = contents /TESTFORUM2####
RewriteCond %{REQUEST_URI}!^/testforum2/.*
RewriteCond %{HTTP_HOST} testdirect2\.domain\.com [NC]
RewriteRule (.*) /testforum2/$1 [L]
#4 ***********************************
#### Non-servr Calls to /TESTFORUM2 = TESTDIRECT2.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testforum2/
RewriteRule ^testforum2/(.*) [testdirect2.domain.com...] [R=301,L]
#### Non-servr Calls to /TESTDIRECT2 = TESTDIRECT2.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testdirect2/
RewriteRule ^testdirect2/(.*) [testdirect2.domain.com...] [R=301,L]
##############
The foregoing allows the use of all the following urls,
which will are all rewritten to appear to the user to be resolving to
- testdirect2.domain.com - ...which is the url that gets passed out.
Also to note, if php is being used, no additional php scripting is required!
LINK1 = testdirect2.domain.com
LINK2 = www.testdirect2.domain.com
LINK3 = domain.com/testdirect2
LINK4 = www.domain.com/testdirect2
LINK5 = domain.com/testforum2
LINK6 = www.domain.com/testforum2
...all roads appear to lead, and/or actually lead, to one...
---------------------------------------
I did not include addressing the following potential urls because of they seem to me to be the least likely concern, but I may do it later...
LINK9 = testforum2.domain.com (not addressed in the above code [yet])
LINK10 = www.testforum2.domain.com (not addressed in the above code [yet])
###############################################################
##### If you copy this code, be sure to 1) replace pipes "¦" with real ones, and 2) add spaces in front of "!" if/where need be because of the forums' auto re-editing of the code ####
########## END REWRITE URLS (4 Sections)############
The process is simple:
Define DNS for any/all subdomains that you wish to use, pointing them at the IP address of your server.
Using virtual host configuration or a *rewrite (mod_rewrite), map those subdomains to subdirectories within that server.
In case someone goes fishing and discovers your subdirectories which support subdomains, you should *redirect direct client requests for those subdiriectories back to the appropriate subdomain URL.
If you wish to keep search engine spiders out of a subdomain, simply place a robots.txt file in that subdomain's top-level directory+ to exclude them.
* Note the disitinction of rewrite versus redirect, this is critical.
+ As far as search engines are concerned, each subdomain is a separate and distinct 'site.' And beyond that, remember that they index and rank pages, not sites.
My advice on this project is to keep it very simple. Experiment, test, and get a simple case completely working, then add 'features' one-at-a-time, re-testing everything done previously to make sure that new additions don't break previously-tested functions.
Jim
But the one point that stands out is that you cannot redirect a subfolder to a subdomain if that subdomain is not defined in DNS. It simply cannot be done, as the browser will be unable to retrieve the IP address to which it should send requests for that subdomain. Therefore, any discussion of subdomains which are not defined in DNS --even if only by wold-card DNS-- is futile.
<BONK on Deh HAid!>
DU-OHH!.. thank you! It occurs to me that I could not get it working until I added wildcard Server Alias in httpd.conf, and then wildcard DNS "A" pointer to the ip. That must be what's causing my only seemingly 'totally virutal' subdomain method to be in compliance with the rule you state (and thus functioning)!
Just for kicks, to help bring focus to it in case you or anyone else care to look at it without wading in the last post (but don't get me wrong, I am not pushing at this point, you really pointed me in the right direction and I thank you again)...
...the "bottom line"s of code doing the scenario 2 thing (excerpted from my previous post) are these:
#3
#### This is a Non-DNS Assigned Folder####
#### Calls to TESTDIRECT2.DOM.COM = contents /TESTFORUM2####
RewriteCond %{REQUEST_URI}!^/testforum2/.*
RewriteCond %{HTTP_HOST} testdirect2\.domain\.com [NC]
RewriteRule (.*) /testforum2/$1 [L]
#4 Then =====================
#### Non-servr Calls to /TESTFORUM2 = TESTDIRECT2.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testforum2/
RewriteRule ^testforum2/(.*) [testdirect2.domain.com...] [R=301,L]
#### Non-servr Calls to /TESTDIRECT2 = TESTDIRECT2.DOM.COM (as defined in #3 above)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /testdirect2/
RewriteRule ^testdirect2/(.*) [testdirect2.domain.com...] [R=301,L]
##############
And considering what JD has pointed out, with wildcard aliasing you do not need to set a DNS rule for the specified subdomain (but you certainly can if/where you want).
Sweet. I hope anyone coming here looking for an education, like me, may find this post helpful. In my second post is all the code.
Thanks to everyone who helped, and thanks so much JD for sharing your fine-tuned understandings!
Cheers,
TwoHawks