Forum Moderators: phranque
# Declare custom error document filepaths
ErrorDocument 403 /v-web/errdocs/403.html
ErrorDocument 401 /v-web/errdocs/401.html
ErrorDocument 500 /v-web/errdocs/500.html
ErrorDocument 400 /v-web/errdocs/400.html
ErrorDocument 404 /v-web/errdocs/404.html
#
# Enable mod_rewrite
RewriteEngine On
#
# 3. A new page called /quotes/ needs to go to https://www.example.com/quotes/ as
# that is the only page I want my SSL to display with https.
# Externally redirect direct client requests for /quote.php or /quotes.php or /quote/ to /quotes/
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /quote(/|s?\.php)([?#][^\ ]*)?\ HTTP/
RewriteRule ^quote(/|s?\.php)$ https://www.example.com/quotes/ [R=301,L]
#
# 3. A new page called /quotes/ needs to go to https://www.example.com/quotes/ as
# that is the only page I want my SSL to display with https.
# Externally redirect non-https requests for /quote/ or /quotes/ or /quote.php or /quotes.php to https
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^quotes?(/|\.php)$ https://www.example.com/quotes/ [R=301,L]
#
# 4. all other pages on the site need to be http and not https
# Externally redirect all https requests for non-https pages back to http.
# (Note that all included-object types that are 'shared' between http and
# https pages are excluded, and that you may need to modify this list.)
RewriteCond %{SERVER_PORT} =443
RewriteCond $1 !\.(gif|jpe?g|png|css|js)$ [NC]
RewriteCond $1 !quotes(/|\.php)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect direct client requests for /index.htm or /index.html
# at any directory level to "/" at that same directory level
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.html?([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
#
# 2. certain very old pages (pre Wordpress) need to be redirected to their respective new page
# Externally redirect requests for /homepage/ subdirectory to "/"
RewriteRule ^homepage(/.*)$ http://www.example.com$1 [R=301,L]
#
# 1. example.com should go to www.example.com (This works in the current htaccess file)
# Externally redirect all non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]