Without knowing exactly what you did, it’s hard to say why it’s doing it. What did you put in the .htaccess? What did you put in headers.php?
<?php
$host = $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'];
$request = $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI'];
header("HTTP/1.0 301 Moved Permanently");
header("Location: http://www.$host$request");
header("Connection: close");
?>
but I deleted it and uploaded the original headers.php so I don´t know how this should have caused a problem. However you are right that this did cause the original problem of making my site appear like http://www.www.cheap-etcetera when I tried to type in xxwww.cheap-webhosting.in
btw I edited my link as the backticks don´t seem to work – I don´t want to raise suspicions of spamming
It’s not spamming when it’s relevant information. Don’t worry about it.
Okay, assuming you have an unmodified headers.php file and have no stuff in the .htaccess to do it, then it shouldn’t be automatically adding www, correct? Or what? I’m confused as to what exactly is going on.. or rather, what question you’re asking. If you undid what you did, then what’s the issue?
Things don’t happen for no reason, so if it’s still doing it, then you didn’t really undo what you did in the first place.
Anyway, the correct way to force www is as follows:
1. Change all references on the blog to have the www. This means changing the stuff on Options->General to have the www. Note, before changing these, the www url must actually *work* to get to the site.
2. Add this to the very top of the .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
That will redirect all incoming traffic for non-www urls to the www one.
I do something similar to this, except I force it the other way, to not have a www. This is basically how I do it.
Ok, thank you those are the steps I will try to implement.
First I need to get rid of this persistent and mysterious redirection that changes my http://www.cheap- urls to get an extra www.
This is my .htaccess `# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress`
Just checked and there is nothing left in my headers.php either. There is no .htaccess in a folder above that could cause this. I´m really a bit clueless what else to try.
Could I just unzip the new wp2.1.3 and keep my wp-config.php plus the upload folder and maybe two or three other files to overwrite the whole thing.
I’m starting to consider a more forceful approach to problem solving at this stage 😉
Hey, just to make sure, have you tried another browser? Or clearing the browser cache? Or even restarting the browser?
Redirections get cached in browsers like anything else.
Thank you Otto, clearing the cache really worked. I completed step 1 but am still having a problem with the redirect.
I implemented your htaccess directive in the root directory of http://www.cheap-webhosting.in/
if you go there and click the non www link in the top right to my blog you will see that it doesn’t get redirected.
When I put this directive in the folder of my blog it just redirects to my home page.
Is there something I missed?