E-Commerce Newbie
Page: htaccess tricks

Start Here!
   Domain Name
   Web Hosting
   Affiliate Marketing
   Websites
   Stores
   Product Reviews
   Sales Letters And Squeeze Pages
   Blogs
   Forums
   Web Directory
   PLR Websites
   Dating & Community
   Membership Websites
   How To Build An Online Store
   Web Site Building Software
   Writing Websites
   Website Promotion
Store
   Free
   Templates
   List Building Materials
   Tracking Software
   Niche Mini Sites
   Web Site Builders
   Maximize Sales
   Ad Creators
   Joint Venture Software
   Security
   Webmaster Tools
Resources
   Affiliate Programs
   Free Webmaster Tools
   E-Commerce Online Tools
   Keyword Density
   Associated Keyword Finder
   Free pdf Convertor
   HTML Tips
   Html Colour Codes
   Tables
   Scripts
   Htaccess Tricks
   DLG Membership Test
Articles
   Affiliate Marketing
   Adult Affiliate Marketing
   Affiliate Marketing Forum
   Affiliate Marketing Networks
   Affiliate Marketing Software
   Affiliate Marketing Tool
   Affiliate Marketing Tracking
   Affiliate Marketing Newbie
   Affiliate Sales without Website
   Wordpress Review Site
   Super Affiliate Training
   Domain Names
   Buying Domain Names
   Buy Sell Domain Names
   Domain Name Value
   Domain Value Calculator
   Email Domain Hosting
   Sell Domain Name
   Transfer Domain Names
   Whois Domain Name Search
   List Building
   Building an email list
   List Building Service
   List Building System
   List Building Techniques
   List Building Tools
Courses
Definitions
Contact Us
Privacy

Htaccess Tricks

Having trouble getting your website to work just the way you want? Here are a few simple htaccess tricks you can use to perform some basic tasks.

FTP into your site or use file manager in Cpanel, your .htaccess file will be located in your sites root folder. You may not have a .htaccess file if you don't see a file named .htaccess you can easily create one using notepad.

Open Notepad add the lines of code you want & save it as .htaccess then upload to your root directory.

Simple .htaccess redirect code

Redirect pagetoredirect.html /redirect.html

or Off Site Redirecting

Redirect pagetoredirect.html http://site.url/page.html

NOTE: You can use the off site redirecting for affiliate links

301 Redirect

redirect 301 /olddirectory/oldpage.htm http://www.yoursite.com/newpage.htm

Good for republishing existing sites with different page names

Displaying PHP includes in .htm & .html pages. 

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

Some servers require the php version as well

AddType application/x-httpd-php5 .php .html .htm
AddHandler application/x-httpd-php5 .htm .html

Custom error code redirects

ErrorDocument 400 /yourcustom400page.html
ErrorDocument 401 /yourcustom401page.html
ErrorDocument 403 /yourcustom403page.html
ErrorDocument 404 /yourcustom404page.html
ErrorDocument 500 /yourcustom500page.html

You can add more lines & errors if you wish - Remember to create & upload your custom error pages first.

Tidy public_html

As you build your website you will create sub folders for content & for various programs you may install.

You will also generate sub folders in your public_html folder for all Sub domains & Addon domains, to say the least your Public_html folder will become very cluttered & it becomes harder & harder to distinguish between your site & the other domains.

An easy way to avoid this issue is by creating another folder in your public_html folder either using ftp or File Manager. Name the new folder after your main Domain Name.

Add a .htaccess file into your public_html then add the following code:

# Turn on rewrites.
RewriteEngine on

# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$

# Only apply to URLs that aren't already under folder.
RewriteCond %{REQUEST_URI} !^/newfolder/

# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /newfolder/$1

# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$
RewriteRule ^(/)?$ /newfolder/index.html

Modify the bold script to match your site. This will make the sub folder appear as if it is your public_html folder.

As you add more web sites (addon domains) the domain folders will be neatly installed alphabetically in your public_html folder

To ensure you keep you sites organized in the future you need to take care when adding subdomains - Subdomains are usually created outside of the parent domain folder by default. For better organization it is better to change the install path of your subdomains to inside the domains root folder.