OK, we need a little help with some domain redirects from some experts please. I’ll post the code we have currently in the .htaccess file a little further down, but I’ll explain what we are trying to achieve:
1. primary domain (primary.com in code below), should always use www prefix2. primary domain should always use /en/ as the main “home” page3. any parked domains on this account should redirect to primary domain
What we have below actually works and does everything we asked for above, however what we now want to do is redirect a few parked domains (not “all” parked domains) to specific urls, whilst leaving any others that are not specifically redirected continuing to redirect to the primary domain.
So, for example, if visitor accesses “parkedomain1.com” (with or without www), they would be redirected to “
Or, if visitor accesses “parkedomain2.com” (with or without www), they would be redirected to “
But if visitor accesses “any” other parked domain, they’d continue to be redirected to the primary domain (a catchall as it were).
We’re trying to make the .htaccess file as small as possible, and without having to specifically list “all” parked domains with specific redirects as it makes the file too large, we’d like to find a solution where we explicitly list the parked domains we want to redirect to specific urls only, and have a catchall for anything else not specifically listed.
Hope that makes sense, and hope you can help! ?
Here’s the code we’re using currently:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z.]+)?primary.
RewriteCond %{HTTP_HOST} !^www.
RewriteRule .? http://www.%1primary.com%{REQUEST_URI} [R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.primary.com [NC]
RewriteRule ^(.*)$
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /en/ [R=301]
</IfModule>
Header unset ETag
FileETag None
<IfModule deflate_module>
<IfModule filter_module>
AddOutputFilterByType DEFLATE text/plain text/html
AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf
AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf
</IfModule>
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 2 days”
</IfModule>
SetEnv TZ Asia/Bangkok
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>