Quote:
Originally Posted by Vacman
I know that .htaccess files and their associated content has been discussed extensively here and elsewhere, but I would love to see a good example of one with the focus on CDSEO - Jon, can you post a sample for us all?
|
.htaccess files should differ depending on the site but here's an example template to start from:
Code:
Options -Indexes
Options -Multiviews
# This directory index is recommended to replace the
# x-cart default within this .htaccess file
DirectoryIndex home.php index.html index.php
# Enable mod rewrite engine
RewriteEngine On
# Some servers require the Rewritebase directive to be enabled
# Remove # at the beginning of this line to enable:
RewriteBase /
# Force www.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
# / WCM - Force www.
# Force HTTPS
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Force trailing slashes on folders
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
# Redirect access to pages.php when no query string specified
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^pages.php$ https://%{HTTP_HOST}/ [R=301,L]
# .htpasswd protection
ErrorDocument 401 "Unauthorized"
# Default 500 errors
ErrorDocument 500 "Internal Server Error"
# Don't allow access to printable pages
RewriteCond %{QUERY_STRING} printable=
RewriteRule ^(.*)$ - [F]
# Block access to sensitive files types
RedirectMatch permanent ^.*.(ini|tpl|sql|log|conf|bak)$ https://%{HTTP_HOST}/error_message.php
# Block access to sensitive files
RedirectMatch permanent ^.*/.pgp/.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/sql/.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/schemes/.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/upgrade/.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/COPYRIGHT https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/INSTALL.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/NEW.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/README https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/UPGRADE.*$ https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/VERSION https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/include/version.php https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/config.php https://%{HTTP_HOST}/error_message.php
RedirectMatch permanent ^.*/top.inc.php https://%{HTTP_HOST}/error_message.php
# Uncomment this line if installing
RedirectMatch permanent ^.*/install.php$ https://%{HTTP_HOST}/error_message.php
# Add any custom Redirects here
# CDSEO
RewriteCond %{REQUEST_URI} !^/(payment|admin|provider|partner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ cdseopro.php
# Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>