Sample htaccess file

This is a sample htaccess file, and this is what the htaccess file looks like after following the steps shown above. Its really easy to follow and understand if you've followed everything up to this point.


# DO NOT MODIFY THIS SECTION

<IfModule mod_expires.c>

# Enable expirations

ExpiresActive On

# Default directive

ExpiresDefault "access plus 1 year"

# My favicon

ExpiresByType image/x-icon "access plus 1 year"

# Images

ExpiresByType image/gif "access plus 1 month"

ExpiresByType image/png "access plus 1 month"

ExpiresByType image/jpg "access plus 1 month"

ExpiresByType image/jpeg "access plus 1 month"

# CSS

ExpiresByType text/css "access 1 month"

# Javascript

ExpiresByType application/javascript "access plus 1 year"

</IfModule>


# DO NOT MODIFY THIS SECTION

RewriteEngine on

RewriteCond %{HTTPS} =off

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*)$ $1.php [L]


# Main RewriteRule (This section Can be modified)

RewriteRule ^/?$ /home [R=302,L]

RewriteRule ^$ /home [R=302,L]

RewriteRule ^home$ /index.html [L]


RewriteRule ^en/help/ContactMe$ /contact.html [L]


# Reverse the last example to work in opposite direction

RewriteRule ^index$ /en/2015/April/index.php [L]


# Create a page Redirect [Permanent Redirect]

RewriteRule ^about$ /home.php [R=301,L]


# Create a page Redirect [Temporary Redirect]

RewriteRule ^about$ /home.html [R=302,L]


# Make your folders private

Options -Indexes


# Make your folders visible to everyone

# Options +Indexes


# Redirect direct HP and Domain access to an HTTPS/SSL name

RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.yourdomain.com$

RewriteRule ^/?$ https://yourdomain.com/pageofchoice [R=301,L]

RewriteRule ^$ https://yourdomain.com/pageofchoice [R=301,L]


# IP Detection and redirection to appropriate domain/country site

# Redirect all IP address (replace the ## with the IP address # numerals) to same http://yourdomain.ca

RewriteCond %{HTT_HOST} ^##\.##\.##\.##

RewriteRule (.*) http://yourdomain.ca/$1 [R=301,L]


# This section below is for overwriting all pages

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{REQUEST_URI} !/hiatus\.php$

RewriteRule ^(.*)$ /Hiatus [R=302,L]


# Make your folders read specific PHP Versions

AddHandler application/x-httpd-php55 .php .php5 .php4 .php3


# Simple Password Protected file

# Restricted Access

AuthUserFile /home/username/.htpasswds/public_html/passwd

AuthName "RESTRICTED AREA"

AuthType Basic

<files "filename.php">

Require valid-user

</files>

Converted from CHM to HTML with chm2web Standard 2.85 (unicode)