Posted on August 19th, 2007 by Oleg K
Tags: Code Snippets htaccess index.htm non www pagerank redirect root www People (or you) can link to you to your homepage using four different urls:
http://www.domain.com
http://domain.com
http://www.domain.com/index.html
http://domain.com/index.html
So you are dividing your one page’s pagerank amongst those urls. What you want is for those urls to all be 301 (permanent) redirected to one page, optimally one without the index.html (since later on you may choose to use index.php or other). This can be accomplished with a few simple .htaccess redirects.
First thing you want to do is choose whether you want www.domain.com or domain.com
domain.com >> www.domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
www.domain.com >> domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
Replace domain.com with your domain.
Source: enarion.net
Then you want to redirect your index.html/htm/php/any other extension to the folder
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.domain.com/$1 [R=301,L]
Replace index.php with your index.extension and www.domain.com with your domain
Source: Search Masters
Put it into your root folder and viola! You’ve just concentrated 4 pages of pagerank into one!
Filed under: Code Snippets | 1 Comment »
Posted on August 12th, 2007 by Oleg K
Tags: apache Code Snippets complete guides flags htaccess mod rewrite navigation pretty code redirect root Just like any coder and webmaster, we need to use .htaccess to make our lives easier and websites better. Whether you are rewriting ugly code to make it pretty or making up pages to increase your index (will post about this later), .htaccess is the diamond in the rough that will make you cry when you don’t know how to work it.
I’ve gone through literally hundreds of pages looking for a single, complete guide to .htacess and have yet to find one. So I’ll just share those links and some information that they don’t have here.
Ultimate Guide to htaccess and mod_rewrite
This is one of the more complete guides I’ve seen on .htaccess and mod_rewrite
The only thing that is missing is what each “flag” means so here they are..
[F] - Forbidden - Won’t show the page
[L] - Last Rule - If the conditions are met, then this is the last rule that is processed
[R=code] - Redirect - Used for redirects. code = 301 for permanent redirects and 302 for temporary
[NC] - No Case - upper case/lower case/proper case, doesn’t matter
These codes I got from mod_rewrite, a beginner’s guide (with examples) which is another great guide to .htaccess.
For a huge guide, check out Stupid htaccess Tricks. This is the biggest and, in my opinion, best guide out there. It has all of the flags, table of contents for easy navigation, tons of “stupid”, yet absolutely vital, tricks for your site.
Filed under: Code Snippets | 1 Comment »