Coding Your HTAccess File

Website Design and Optimization

A few years ago I built my first web site - navycs.com. I knew absolutely nothing of HTML and proper coding. Nor did I have a clue how to reach people on the web, so began the journey. Navy Cyberspace has become my portal to help provide accurate military recruiting and benefit information. This site is growing larger everyday.

I owe a great deal of my knowledge to those on search engine optimization (SEO) forums like, SEO Chat, SEOChat is a friendly place with some of the most knowledgeable and respected people in the business, and SEO Refugee who's members deliver great information with a unique and casual flair.

I have run tests on various the components of search engine optimization to help myself better understand. One such test included the use of the keyword meta and title attribute test which measured their weight on placement within the search engine result pages (SERP).

Web Site Coding

Web Site Coding Standards

Web site coding standards. The World Wide Web Consortium is the coding standard by which you should develop your web pages. Properly coding your pages will not increase your SERP placement but does speck positively to your visitors. It is just the right and professional thing to do!

.HTACCESS File

The various .htaccess coding suggestions below are recommendations which could have a positive effect on your web sites SERP placement. The .htaccess file is a file that only could be used when operating an Apache server. If you are operating a dedicated server your httpd.conf file located in your servers conf folder would need to have the command "AccessFileName" providing guidence to the server to look in the .htaccess for additional configuration directives in each directory. The command "AllowOverride" would also have to be set as it controls what directives may be placed in .htaccess files.

It has been my experience that a majority of shared hosting services will allow the use of the .htaccess file to perform the following server guidence suggestions;

non-www to www code

The following code is used to 301 redirect your non WWW version (http://yourdomain.com) of your website to the WWW version (http://www.yourdomain.com).

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=permanent,L]

Index.html to /

If you are using a different file extension the replace the "html" with your extension. The following code will 301 redirect your index (http://www.yourdomain.com/index.html) to http://www.yourdomain.com/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]

Folder/index.php to Folder/

If you are using a different file extension the replace the "php" with your extension and replace "folder" with your actual folder name. Ensure the code is placed into your root htaccess file (http://www.yourdomain/.htaccess). Note: The folder cannot have a dedicated htacccess as it will over-ride the commands from the root file. The following code will 301 redirect your index (http://www.yourdomain.com/folder/index.php) to http://www.yourdomain.com/folder/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*folder/index\.php\ HTTP/
RewriteRule ^(.*)folder/index\.php$ /folder/$1 [R=301,L]

301 Redirect Old page to New Page

Redirect 301 /oldpage.html http://www.yourdomain.com/newpage.html

301 Redirect Old Web Site to New Web Site/

If you have a domain you control and you wish to have the entire site redirct to a new domain name then use the following code. Ensure you replace the yourolddomain with the site you wish to redirect and the yournewdomain with the site you wish to redirect to.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*yourolddomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yournewdomain.com/$1 [R=301,L]

Parse php in html pages

AddType application/x-httpd-php .php .html

Contact your sever host if you find the modifications are not working to ensure the correct permissions are granted by your server host.

NavyCS CounterStrike is not affiliated with any military recruiting organizations. | ©2010 NavyCS
Site Map