Forum Moderators: phranque
redirect 301 [my.com...] [my.com...]
Code 2
if($_SERVER['HTTP_HOST']=='example.com') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: [example.com...]
header("Connection: close");
}
www.mysite.net/ rates a PR of 6/10 on one online checker.
mysite.net/ only rates 2/10. ( i.e. no www. )
Will a redirect indeed improve the PR for the real url with the www in it?
Could this help with my positioning in the SERPs?
- Larry
This is code for in an .htaccess, redirects requests without the www to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.tld [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [R=301,L]
can i add this code for all my pages having same problem instead of main website url.will this help me more?
as i have seen that i have urls of different pages listed in engines without and with www both so will this help me with added advantage?
Once again thanks for your code
With Regards and Best wishes
1) Do I need a statment 'RewriteEngine Off' at the end?
My first experiment with .htaccess shut down my entire site, so I'm really leery ..
2) Do I save .htaccess to the root directory on my host ISP,
i.e. right alongside index.html, or someplace else?
3) Does this count as a classical '301 redirect' so often mentioned in these discussions?
4) IF SO, do any ratings or rankings benefits accrue to my main www.mysite.net pages?
5) I have no .htaccess file in use now. If I put one up with the 301 redirect as given,
can I ADD exclusions to the very same file later?
(That would be to exclude obnoxious robots.)
- Larry
1) Do I need a statment 'RewriteEngine Off' at the end?
My first experiment with .htaccess shut down my entire site, so I'm really leery ..
You just write your domain name and .com .org etc. i place of tld
2) Do I save .htaccess to the root directory on my host ISP,
i.e. right alongside index.html, or someplace else?
You have .htaccess file in www or public_html directory its same where other pages are
3) Does this count as a classical '301 redirect' so often mentioned in these discussions?
Dont know about this wd like to know more
4) IF SO, do any ratings or rankings benefits accrue to my main www.mysite.net pages?
As far as i know our rating should go up faster then otherwise as this wd help google to club pages faster otherwise it wd have taken atleast 6 months
5) I have no .htaccess file in use now. If I put one up with the 301 redirect as given,
can I ADD exclusions to the very same file later?
(That would be to exclude obnoxious robots
You can just make a .htaccess file with notepad and add the code as written above ,place it in ur root
2) Yes, save it to the root. Where your index.html lives.
3) Yes, this is classical 301.
4) From what I've seen in Google and read in these forums Pagerank is not related to ranking in the SERPS. But you should benefit from this. In the Google forum are stories about sites that disappeared from the SERPS because of duplicate content, caused by this. Actually, www is a subdomain from domain.tld. So it's important to redirect one to the other.
5) Once you have an .htaccess on your domain you can add all kinds of rewrites, redirects, etc to the same file.
You have answered all my questions clearly, simply and directly.
I presume I can create an .htaccess file as htaccess.txt, then upload it as such,
and finally rename it to .htaccess once up at the host directory.
If the world comes to an end, I can just erase it.
If not, this may make an interesting test.
Right now, my index.html page comes up #25-30 (3rd page) on Google for my main short keyword.
If this changes much, I will have learned something.
Best
- Larry
As a test, I called up [mydomain.net....]
Up popped [mydomain.net....]
Same thing worked with other file names, no-www ==> www on 3rd level pages.
Wow! My very first real 301 redirect. Maybe I should bake a cake.
One strange thing! When I sent up htaccess.txt, it showed in my host's directory as expected.
Once I RENAMED it to .htaccess, it vanished from the visible directory!
Is this normal?
Thanks again - Larry
> Do I need a "RewriteEngine off" directive?
No, not unless you have RewriteRules that you want to disable temporarily. In that case, you can use RewriteEngine off ahead of the rules you want to disable.
Jim
"Files starting with a dot are meant to be invisible.
But somewhere in your FTP program should be a little "Show Invisible Files" button, I hope.. :
I'm using WS_FTPle so FTP files up and down to host.
If somebody knows how to make that display invisible files, I'm all ears.
I don't see any special button or command line to force showing invisible files.
It would be reassuring to see it, but I'd rather not have it publicly available.
I will now experiment to see if I can download .htaccess publicly,
i.e. as another document/page instead of FTPing it.
- Larry
I never found a way to display it in my root directory files list, BUT, I know its there.
Two 'visitors', one in Pakistan, the other in Holland, tried to download it.
This didn't show in access_log, but rather the error.log files.
They got an access denied message of some sort, not a 404-error.
Now I'm wondering why somebody halfway around the world wants my .htaccess information.
Spammers maybe? - Larry