1

I am renting some webspace and a domain from BlueHost.com on which I run a WordPress site. Let's call it example.com. WordPress is installed in the root folder.

As I can run multiple sites on this webspace, I installed a second WordPress site in a subdirectory: example.com/wp2.

I furthermore own a second domain - let's call it example.net - which is rented from nearlyfreespeech.com. I therefore created a .htaccess file which forwards all traffic from example.net to example.com/wp2.

My problem: I can't figure out how to rewrite the URL to show example.net once a user has reached that WordPress site. Right now, the URL changes to example.com/wp2 after accessing the site via example.net.

Many tutorials point out that a .htaccess file should be placed in the root directory of example.com to rewrite the URL. But as I already have a separate WordPress site sitting in that root directly, that doesn't seem to work for me.

How can I rewrite that URL so that people who access the second WordPress site via example.net keep seeing that URL?

  • I wouldn't put different domains in subdirerectories of each other. I'm not sure what type of hosting plan you have, but maybe you can edit virtual host files? If so you can point the second domain to a different folder that isn't within the document root of the first domain. – Stephen Ostermiller Nov 3 '18 at 19:01
  • " I therefore created a .htaccess file ..." - so you also have hosting for the domain second.com at nearlyfreespeech.com? – MrWhite Nov 3 '18 at 21:49
  • @MrWhite Right! I originally used nearlyfreespeech to host my sites but as I ran into some problems there, I moved to a different provider. Might it make sense to transfer the domain, too? Would that solve any of the problems I have? – rocketbamboo Nov 4 '18 at 2:33
1

If example.net points to the second WP installation in the subdirectory /wp2, the corresponding .htaccess should be placed in the wp2 folder, not one level above.

  • The htaccess in root of domain.com rewrites the URLs for the first WP installation, accessible via Domain.com. The root for WP2 is not domain.com, but Domain.com/wp2 – binsky Nov 3 '18 at 18:18
  • Thanks, that makes sense! But even after trying out different ways of rewriting the URL in the .htaccess file and lots of Google I can't get this to work. Either I end up with error messages, nothing at all happens, or I produce a redirect instead of a rewrite. – rocketbamboo Nov 4 '18 at 2:34
  • What URL is specified in WP2? – binsky Nov 4 '18 at 8:06
0

As I can run multiple sites on this webspace, I installed a second WordPress site in a subdirectory: example.com/wp2.

The ability to "run multiple sites on this webspace" is most probably referring to the ability to have multiple domain names pointing to your webspace, rather than having multiple instances of a CMS installed (which you could do anyway, regardless of whether "multiple sites" are permitted or not).

The multiple domains are achieved by creating an "Addon Domain" or "Domain Alias" at BlueHost.com (cPanel terminology, but the idea is the same regardless of the hosting control panel used).

An "Addon Domain" and "Domain Alias" are very similar. A "Domain Alias" is essentially just that, an alias for your main domain and usually points at the main domains document root. An "Addon Domain" on the other hand has its own document root and can point directly to a subdirectory (for example).

You should probably be created example.net as an "Addon Domain" on your BlueHost.com hosting account that points directly to the /wp2 subdirectory.

I furthermore own a second domain - let's call it example.net - which is rented from nearlyfreespeech.com. I therefore created a .htaccess file which forwards all traffic from example.net to example.com/wp2.

Simply 3xx "redirecting" the request from example.net to example.com/wp2 is naturally going to expose example.com. Alternatively, you could create a reverse proxy at your nearlyfreespeech.com (NFS.com) hosting and proxy the requests to example.com/wp2 - but this is a lot more work, requires a hosting account at NSF.com with server-level access.

Instead, you should forget the hosting/.htaccess at NFS.com and point the example.net directly at your example.com account (having created the "Addon Domain" as mentioned above), by either:

  • Create DNS A records for example.net (and www.example.net?) that point to the IP address of your example.com server.
  • Change the NAMESERVERS on example.net to point to BlueHost.com and control the DNS at BlueHost.com instead. BlueHost.com will have already created the necessary A (and CNAME) records at the time you created the "Addon Domain".

If you want you can also transfer the domain to BlueHost.com (and change NAMESERVERS in the process) if you wanted to finish with NFS.com completely. This is entirely up to you. You don't need to change registrar in order to use the domain at BlueHost.com.

No additional .htaccess files or directives are required in this scenario.

Many tutorials point out that a .htaccess file should be placed in the root directory of example.com to rewrite the URL.

Those tutorials would seem to be referring to something else?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.