WWW vs. Non WWW
-
I know this issue has been beat to death here, but my issue is a bit different. So if I go to my site WITH the www (www.ilgenetics.com), everything is great, links all work fine too. If I go there WITHOUT the www, (ilgenetics.com) the homepage still comes up and looks ok, but all the links on the page point to my staging area (staging.ilgenetics.com). My DNS is fine as pinging both with the www and without return the same IP.
What am I missing?
-
Did u installed WP with www. version or naked url (without www) version. I think You installed with www.
Pick www or non-www, then add the following code (see last) to wp-config.php with a slash at the end of
/*toggle on/off*/(like that) to activate the two lines following and then browse your site just a bit, then turn that back off and go to Dashboard > Settings > General and save what you have there. That should update your database to whichever you had selected, but I still also had to do a manual search via phpMyAdmin to find and edit a few places that had somehow been missed. Prior to doing that, however, use something like either of these first two bits of code in .htaccess (if you have .htaccess) to redirect all traffic of one type or the other to the other:RewriteEngine On RewriteBase / # redirect all www. to non-www. RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC] RewriteRule ^(.*)$ http://domainname.com/$1 [R=301,L] RewriteRule ^index\.php$ - [L]RewriteEngine On RewriteBase / # redirect all non-www. to www. RewriteCond %{HTTP_HOST} ^domainname\.com$ [NC] RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=301,L] RewriteRule ^index\.php$ - [L]<?php /** * The base configurations of the WordPress. * * @package WordPress */ /*-either-*/ /** @ root/wp-config.php: /*toggle on/off* define('WP_HOME','http://domain.com'); define('WP_SITEURL','http://domain.com'); /*-or-*/ /** @ root/wp-config.php: /*toggle on/off* define('WP_HOME','http://www.domain.com'); define('WP_SITEURL','http://www.domain.com'); /*-end-*/Sykat – I do not know how it was installed as I am new to this company and inherited it from the last admin. Is there a way via the dashboard to find out how it was installed?
Leejosepho – thanks for that! I tried the following code in my .htaccess and for some reason it blocked access to my dashboard until I went into the AWS server this sits on and copied the old .htaccess without the following code back. Here is the code I used in my .htaccess. Can you see anything wrong with this?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^ilgenetics.com$
RewriteRule ^(.*)$ http://www.ilgenetics.com/$1 [R=301]I do not know enough about .htaccess to help you there, but that appears to be making everything go to http://www. So, I might try adding the non-www-to-www code just above that and see what happens.
If you do end up going into your database, here is the SQL code I used there:
UPDATE pref_options SET option_value = replace(option_value, 'http://www.mydomain.com', 'http://mydomain.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE pref_posts SET guid = replace(guid, 'http://www.mydomain.com','http://mydomain.com'); UPDATE pref_posts SET post_content = replace(post_content, 'http://www.mydomain.com', 'http://mydomain.com'); UPDATE pref_postmeta SET meta_value = replace(meta_value,'http://www.mydomain.com','http://mydomain.com');note: To make non-www into www, just switch
'http://www.mydomain.com','http://mydomain.com');to'http://mydomain.com','http://www.mydomain.com');in all lines.Also, change ‘pref’ to your own table_prefix.
Thanks leejosepho! I will give this a shot!
Hi Again
So I am almost there. I find that I can remedy my issue with the following code in my .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.ilgenetics.COM$ [NC]
RewriteRule ^(.*)$ http://www.ilgenetics.COM/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPressThe problem then lies in the fact that with that code, when I try to access my staging area (staging.ilgenetics.com), it gets redirected to http://www.ilgenetics.com as well. I assume because the above code pushes all traffic bound for a site ending in “ilgenetics.com” to http://www.ilgenetics.com – is there a way to exclude staging.ilgenetics.com from that rule?
Thanks!
If you staging area (its folder or directory) is actually located at something like
http://www.ilgenetics.com/staging/, just use that.Edit: Other than that, possibly so, but I do not know.
Here is something for you. The re-write code in the htaccess file works great…in every browser except Chrome. Why would that be?
I know nothing about using Chrome, but I would suspect some kind of cache issue if you had used it at the site prior to the new htaccess. Even after clearing my cache and history, my Firefox still sometimes comes up with something other than what I want.
The topic ‘WWW vs. Non WWW’ is closed to new replies.