Hypertext Access file
I have multiple domains that share hosting by pointing secondary domains to subdirectories of my primary domain hosting. However, it looks unprofessional when the URL doesn’t match the domain name the client requested, so I want to show that secondary domain name to the client. That means I need a stealth rewrite.
It also looks unprofessional when your site trips that Chrome error about not using HTTPS, so I need to enable SSL through my hosting provider and rewrite everything to HTTPS.
All this can be accomplished by an .htaccess file in the root of the subdirectory where I am pointing my secondary domain. This file does three things:
- Forces everything to use HTTPS
- Sets up a 301 redirect for a domain pointing to a subdirectory
- Includes “stealth” rewrite so this site appears as ‘omnilinguaphile.com’ rather than ‘my-primary-domain.com/omnilinguaphile’
#BEGIN SSL REDIRECT
#Rewrite to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
# Stealth rewrite
#RewriteCond %{HTTP_HOST}^(www.)?omnilinguaphile.com
#END SSL REDIRECT
Note: The .htaccess file is written in the Apache programming language.