By okiedokey

2015-09-07 09:09:26 8 Comments

I have a bunch of domain names with different TLDs. What I want is to point several domains to the "main"-domain which has a SSL cert (single domain).

Like this: (main domain with SSL cert) (should redirect to and rewrite the URLs) (should redirect to and rewrite the URLs)

The https domain points to the directory which contains the website data. I created a subfolder in that directory where I pointed the additional domains to, because I was thinking I could place a htaccess file there to manage redirection and rewriting. Is that OK so far?

I am having trouble finding the correct htaccess rules which permanently redirect the requested domain (either or to and rewrites the URLs correctly.

I tried the simplest thing that came to my mind:

Redirect permanent /

But that resulted in e.g. which, of course, does not work.


I use WordPress and put as blog URL as well as site URL in the settings and I made WordPress force SSL.

Can someone please help?


@MrWhite 2015-09-07 12:39:08

With your additional domains pointing to subdirectories off the main domain's document root, you can add the following to the .htaccess in that subdirectory to redirect to the main domain:

RewriteEngine On
RewriteRule (.*)$1 [R=302,L]

Note that this uses mod_rewrite, not mod_alias (Redirect). As such it will override the mod_rewrite directives in the parent .htaccess file. This assumes that the parent .htaccess file (which includes the WordPress directives) does not use mod_alias. (WordPress usually only uses mod_rewrite.)

Change the 302 (temporary) redirect to a 301 (permanent) redirect when you are happy it's working OK.

An alternative (as mentioned in comments) is to simply point these additional domains to the main domain's document root as opposed to subdirectories. Then, you would need to modify the main domains .htaccess file and include a similar external redirect before the WordPress directives. Something like:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?additionaldomain1\.net$
RewriteRule (.*)$1 [R=302,L]

In fact, you could do this anyway with the subdirectories, and not use the .htaccess file in the subdirectory. .htaccess files are inherited by default.

@okiedokey 2015-09-07 13:00:38

Thank you, very comprehensive! I used the second way you described because it actually makes more sense. But I'm facing the problem that in Firefox, the URL is (which doesn't work and throws an error). In Chrome I'm being redirected, but the URL does not change to and my iconfont does not display unless I use the page navigation to open another site else than front page. Can you imagine why?

@MrWhite 2015-09-07 13:58:49

Trying clearing your browser cache (particularly if you are seeing different results in different browsers). If you had previously tested with 301/permanent redirects then these (incorrect redirects) will have been cached by the browser (which is why it's often preferable to test with 302/temporary redirects). "In Chrome I'm being redirected" - where are you being redirected to, if it's not You might need to add the contents of your .htaccess file to your question so we can check for any conflicts.

@okiedokey 2015-09-07 14:47:25

Duh, pleace excuse my last comment because I'm an idiot. First thing is of course I hadn't thought of the cache. Second, I did not realize my changes to my htaccess file weren't made because FileZilla couldn't reupload the file. I still went with your second advice and it works.... of course!

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] htaccess force HTTPS to main domain and all subdomains

2 Answered Questions

[SOLVED] All pages are not being redirected to HTTPS when accessed using HTTP

3 Answered Questions

[SOLVED] Switching domain from HTTPS to HTTP

1 Answered Questions

1 Answered Questions

[SOLVED] .htaccess doesn't redirect my pages from HTTP to HTTPS

2 Answered Questions

Sponsored Content