Creating an .htaccess file

When creating an htaccess file simply follow these steps.

  1. Always start your file with an Expiration header

# 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>


  1. The next step is to add a RewriteEngine rule needed to make www.yourdomain.com/index.html work as www.yourdomain.com/index

# DO NOT MODIFY THIS SECTION

RewriteEngine on

RewriteCond %{HTTPS} =off

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

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

  1. Now insert the RewriteRule code for the page you wish to have the way it is accessed changed

# Main RewriteRule (This section Can be modified)

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

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

RewriteRule ^home$ /index.html [L]


  1. Have a file that is not found in a folder appear as though it is


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


  1. Have a file that IS in a folder appear as though it's in another folder


RewriteRule ^en/HelpCenter/Bugs$ /help/center/bug-report.html [L]


  1. Have a file that is located in a folder appear as though it is not


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


  1. Please note that example 7 and 8 can not be used at the same time, one or the other. Otherwise you will get a 500 Internal Server Error.

  2. Make your folders private


# Make your folders private

Options -Indexes


  1. . Make your folders non-private


# Make your folders visible to everyone

Options +Indexes


  1. Creating a Comment

    To create a comment, simply place a # in-front of the phrase you wish for the server to ignore

    Ex:

    # Make your folders visible to everyone

    Options +Indexes


  1. Make sure that all php versions are compatible with your website


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






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