Forum Moderators: phranque

Message Too Old, No Replies

www.mydomain.com -> mydomain.com or vice versa?

when mydomain.com got suddenly PR 0.

         

maggi

8:56 am on Jul 19, 2004 (gmt 0)

10+ Year Member



Dmoz and 6 similar sites had listed www.mydomain.com and I got PR 4.
The page mydomain.com had identical PR4 and apr. 30 backlinks from internal content pages and some external links.
I added 4 weeks ago appr. 1000 pages all linking back to mydomain.com.
All these pages are indexed since 14 days and show PR0 - thats normal.
Now I see for the page [mydomain.com...] PR 0
and link:http://mydomain.com/ shows no nothing.

1. Is that a reason of the massive backlinking from page_from_own_site with PR 0?

2. Is it wise now to "concentrate" the PR of www.mydomain.com and mydomain.com to a single page?

I found an example for mydomain.com -> www.mydomain.com
rewriteCond %{HTTP_HOST}!^www\.mydomain\.com
rewriteRule ^(.*)$ [mydomain.com...] [R=permanent,L]

but my favorite in this situation would be
www.mydomain.com -> mydomain.com because then the entire linking structure would be unchanged for the Google spider.
3. Is that the right aproach?

RewriteCond %{HTTP_HOST}!^mydomain\.com.*
RewriteRule ^http://www.mydomain.com(.*)$ [mydomain.com$1...] [R=permanent]

Thats working.
4. Can that be optimized?
Thanks, Maggy

maggi

12:06 pm on Jul 19, 2004 (gmt 0)

10+ Year Member



Sorry, my mod_rewrite example above was not correct.
I changed it to:
RewriteCond %{HTTP_HOST}!^mydomain.com.*
RewriteRule ^(.*)$ [mydomain.com$1...] [R=permanent]
I wonder why the syntax in some examples escapes the "." in the domainname.
RewriteCond %{HTTP_HOST}!^mydomain\.com.*
Thanks, Maggy

jdMorgan

2:28 pm on Jul 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



maggi,

Various characters, including periods, have special meaning in the regular expressions patterns used by mod_rewrite. The period must be escaped or it will mean "match any character." This code is right for your stated purposes if installed in httpd.conf:


RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteRule (.*) http://www.mydomain.com$1 [R=permanent,L]

If you have a DMOZ listing pointed to "www" and PR4 on that subdomain, then that's the one you should use. So redirect non-www to www using the code above. It will be far easier to update your site to consistently refer to www, than it will be to get your ODP listing changed and get Googlebot to switch the PR over.

On a new site, it does not matter which you use, the domain mydomain.com or the subdomain www.mydomain.com, but the best results will be had if you consistently use only one of them.

Don't use any code on your server until you fully understand it. I recommend the following references:

Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]

Jim

maggi

6:33 am on Jul 20, 2004 (gmt 0)

10+ Year Member



So in my example
!^www\.mydomain.com
the unescaped dot could be "any character"
and the condition has acepted the "." among every other character.
--
The condition
!^www\.mydomain\.com
has a specific "." due to the escaped "\."
Thanks a lot

jdMorgan

3:25 pm on Jul 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it is a matter of increasing the pattern precision, and avoing unexpected matches on "any character".

Jim

Jammer

6:00 am on Jul 21, 2004 (gmt 0)

10+ Year Member



Does this code change what url is on the browser?

I want to make sure even if a person types mydomain.com they end up being 'redirected' to www.mydomain.com

When I tested your code it did not seem to work - is it supposed to do that?

I want to force everyone to only ever see www.mydomain.com.au no matter what they type.

maggi

6:54 am on Jul 21, 2004 (gmt 0)

10+ Year Member



In my example above a "blank" before the "!" is catched by the forum software, that might be the error.
>>I found an example for mydomain.com -> www.mydomain.com
rewriteCond %{HTTP_HOST} "blank"!^www\.mydomain\.com
rewriteRule ^(.*)$ [mydomain.com...] [R=permanent,L]

Jammer

7:41 am on Jul 21, 2004 (gmt 0)

10+ Year Member



That works fine now thanks...

kwasher

4:12 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



Do both of these rules acheive the same exact desired END RESULT? (redirecting domain.com to www.domain.com)

The first is the one I've been using which I lifted from here a long time ago. The second is the one a friend is using. (the forum software changes some things after you post here, but the gist of the point is still the same)

RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule (.*) [domain.com...] [R=301,L]

--

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

jdMorgan

6:36 pm on Jul 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They accomplish almost the same thing.

The first version redirects all except "www.domain.com" to www.domain.com, while the second only redirects "domain.com" to www.domain.com. For a site where only these two domain variations exist, they do the same thing, but in different ways.

Also note that as member Gergoe has pointed out, the first version should always test to make sure that the {HTTP_HOST} is not blank, as it would be for HTTP/1.0 requests:


RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

Without the HTTP_HOST check, the code would put an HTTP/1.0 request into an infinte loop, since true HTTP/1.0 requests do not contain a Hostname header, and a blank HostName is not equal to "www.domain.com". Note also that I removed the [NC] flag on the second RewriteCond; It is neither necessary nor desirable if the purpose is to standardize on one domain name. [NC] should not be used in the other version, either.

Jim

kwasher

7:29 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



Wow. infinite loop land. Time to change some files!

Thank you for the (always great) info.

kwasher

7:58 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



JD, discussing the very last code you gave in your post, the questions came up-

- What happens to subdomains? They dont seem to get redirected, but the code statement appears to say they should.?

- Is it better to redirect from www.domain.com to domain.com (so you only have essentially one domain live, since www is a subdomain itself) than redirect from domain.com to www.domain.com (where you end up having two domains live).

Oh, and we wondered what happens to PR (is it split between www.domain.com and domain.com). But that might be a question for another day and another thread in a different forum.

Would anyone like a beer?

jdMorgan

8:08 pm on Jul 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Subdomains will be redirected if and only if they are pointed to the directory structure where the redirect code is installed. If the code is not executed, it can have no effect.

There is no technical reason to prefer www vs. non-www. Make the choice based on existing incoming links, branding issues, and length of URLs.

If you have back-links of both www- and non-www forms, then it is possible that your PageRank is split across these two domains. Google usually resolves this for www- and non-www, but why depend on third parties when you can control it?

Jim

kwasher

8:24 pm on Jul 23, 2004 (gmt 0)

10+ Year Member



Ah ha. By george I think I've got it. And the subdirectory which 'contains' the subdomain has its own htaccess. Thanks again.