Forum Moderators: phranque
You can find tons of examples with google and other SE:
[google.com...]
I wrote several different versions for people with different needs.
If you explain more about what you want, what you have tried,
maybe I can suggest one that you may like.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com$ [NC]
RewriteRule !^/*subdirectory/ subdirectory%{REQUEST_URI} [L]
If you want subdomains of that parked domain to go to the same directory:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+\.)?parked-domain\.com$ [NC]
RewriteRule !^/*subdirectory/ subdirectory%{REQUEST_URI} [L]
Also, you want to use the fix for missing trailing slash problems
if you use the domain name with 'www'.
(Put it before other Rules.)
RewriteRule ^/*(.+/)?([^.]*[^/])$ [%{HTTP_HOST}...] [L,R=301]
If you want to cover both http and https:
RewriteCond s%{HTTPS} ^((s)on¦s.*)$ [NC]
RewriteRule ^/*(.+/)?([^.]*[^/])$ http%2://%{HTTP_HOST}/$1$2/ [L,R=301]
Note: These codes are efficient compared to the code with '-d' check,
but they won't work with directories that have a dot (period) in it.
(ex. /a_directory.name/)
"parked.domain.com:80" is a perfectly-valid value for HTTP_HOST, and will break your rule if the hostname is end-anchored after ".com".
Use:
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com(:[0-9]+)?$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com(:[0-9]{1,5})?$ [NC]
You can use any Mozilla-based browser to test this appended-port problem.
Jim