How can I have all URLs under http://daniweb.com redirect to http://www.daniweb.com for SEO purposes?

You could either use a redirector script (not the best way to do it) or you could make sure your httpd.conf has www.daniweb.com as the ServerName instead of just daniweb.com (if you have control over your server.) My guess is that your httpd.conf has just daniweb.com, but since I don't know too much about your configuration, I'm just guessing there :)

My httpd.conf file does, indeed, have www.daniweb.com as a VirtualHost
I tried adding daniweb.com as well, and that just completely failed - every access to the page was running in circle doing infinite redirects between the two VirtualHosts.

I am pretty sure what I want can be done with .htaccess though. Could someone give me a heads up about that?

And I thought you were the pc gal. You disappoint me Dani...

:P

Personally, I don't use .htaccess if I can do it in httpd.conf. Even the folks over at Apache suggest that. But I digress...

I just did a "dig" on both domains, and found some differences in the results (which should be the same, since they're both on the same box, same server, etc.)

Here's the stdout of daniweb.com:

[email="kevin@Cerberus$"]kevin@Cerberus$[/email] dig http://daniweb.com
; <<>> DiG 8.3 <<>> http://daniweb.com
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;; http://daniweb.com, type = A, class = IN
;; AUTHORITY SECTION:
com. 1h26m24s IN SOA a.gtld-servers.net. nstld.verisign-grs.com. (
1080019309 ; serial
30M ; refresh
15M ; retry
1W ; expiry
15M ) ; minimum

;; Total query time: 18 msec
;; FROM: Cerberus.geekis-kahn.net to SERVER: default -- 167.206.3.166
;; WHEN: Tue Mar 23 13:18:19 2004
;; MSG SIZE sent: 36 rcvd: 109


Here it is for www.daniweb.com:

[email="kevin@Cerberus$"]kevin@Cerberus$[/email] dig http://www.daniweb.com
; <<>> DiG 8.3 <<>> http://www.daniweb.com
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;; http://www.daniweb.com, type = A, class = IN
;; AUTHORITY SECTION:
daniweb.com. 1h25m33s IN SOA ns.propagation.net. hostmaster.propagation.net. (
2003103121 ; serial
1D ; refresh
2H ; retry
5w6d16h ; expiry
8H ) ; minimum

;; Total query time: 19 msec
;; FROM: Cerberus.geekis-kahn.net to SERVER: default -- 167.206.3.166
;; WHEN: Tue Mar 23 13:19:42 2004
;; MSG SIZE sent: 40 rcvd: 105


It doesn't matter how many times I redo it, I always get the same results for both. The DNS servers for www.daniweb.com are different than for daniweb.com, along with the settings for expiry, etc. I don't know that that's the answer you're looking for, but it's a start, at least. I'll do some further checking later today after I get back from a service call and let you know if I can *dig* up any more info :)

My httpd.conf file ony has an entry for www.daniweb.com ... :/ Is this "dig" a result of Network Solutions / Verisign as my registrar, or my host? I'm on a dedicated server. But I'm confused now ;)

Basically, dig is a DNS lookup utility. I just tried it again with the T_ANY switch, and here's the stdout:

kevin@Cerberus$ dig T_ANY daniweb.com
; <<>> DiG 8.3 <<>> T_ANY daniweb.com
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 2
;; QUERY SECTION:
;; daniweb.com, type = A, class = IN
;; ANSWER SECTION:
daniweb.com. 4H IN A 69.13.146.64
;; AUTHORITY SECTION:
daniweb.com. 4H IN NS ns2.propagation.net.
daniweb.com. 4H IN NS ns3.propagation.net.
daniweb.com. 4H IN NS ns4.propagation.net.
daniweb.com. 4H IN NS ns.propagation.net.
daniweb.com. 4H IN NS ns1.lax.propagation.net.
daniweb.com. 4H IN NS ns2.lax.propagation.net.
;; ADDITIONAL SECTION:
ns2.lax.propagation.net. 3h27m28s IN A 66.34.193.2
ns4.propagation.net. 1h23m21s IN A 63.249.128.203
;; Total query time: 72 msec
;; FROM: Cerberus.geekis-kahn.net to SERVER: default -- 167.206.3.166
;; WHEN: Tue Mar 23 13:42:18 2004
;; MSG SIZE sent: 29 rcvd: 203


This is for www.daniweb.com:

kevin@Cerberus$ dig T_ANY www.daniweb.com
; <<>> DiG 8.3 <<>> T_ANY www.daniweb.com
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 3
;; QUERY SECTION:
;; www.daniweb.com, type = A, class = IN
;; ANSWER SECTION:
www.daniweb.com. 4H IN A 69.13.146.64
;; AUTHORITY SECTION:
daniweb.com. 4H IN NS ns1.lax.propagation.net.
daniweb.com. 4H IN NS ns2.lax.propagation.net.
daniweb.com. 4H IN NS ns2.propagation.net.
daniweb.com. 4H IN NS ns3.propagation.net.
daniweb.com. 4H IN NS ns4.propagation.net.
daniweb.com. 4H IN NS ns.propagation.net.
;; ADDITIONAL SECTION:
ns1.lax.propagation.net. 3h49m27s IN A 66.34.193.1
ns2.lax.propagation.net. 3h12m42s IN A 66.34.193.2
ns4.propagation.net. 1h8m35s IN A 63.249.128.203
;; Total query time: 96 msec
;; FROM: Cerberus.geekis-kahn.net to SERVER: default -- 167.206.3.166
;; WHEN: Tue Mar 23 13:57:04 2004
;; MSG SIZE sent: 33 rcvd: 223

The DNS servers appear to be the same for both domains on this search. Let me do some more *cough* digging *cough* and I'll let you know...

OK Cool thanks. propagation.net is my webhost where I have a dedicated server. (Well, duh, that info was obvious already). But, yeah, either in .htaccess or via httpd.conf I'd like to have daniweb.com redirect to www.daniweb.com

My httpd.conf file does, indeed, have www.daniweb.com as a VirtualHost

Is it a VirtualHost or the ServerName? It actually does make a difference...

Also, do you have mod_rewrite enabled/compiled?

I have mod_rewrite enabled and I am currently using it so that my forums and threads have .html exensions ;) i.e. to redirect to the real php pages.

Hi, I am new to your forum, but if I understand your query correctly,
I think you can try the following:

Here goes....

Providing that your DNS is correctly pointed :) and both url's point to the same server, you need to add the following to httpd.conf


#
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client. When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

NameVirtualHost *:80 # if it doesnt exist already
and then in the Virtualhost Container

<VirtualHost *:80>
ServerName www.somedomain.com
ServerAlias somedomain.com
## Some other stuff
</VirtualHost>

This will tell Apache to redirect all requests to any of the above url's to the specified virtual host.

Hope it helps...
:)

I'm not sure if this was said already, but I'll tell you anyways.

You can add "Redirect 301 /index.php http://www.daniweb.com" (without the quotes) to a .htaccess file within your /www or /public_html folder.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.