1

First of all, let me apologize in advance as this may be a poorly worded question. My knowledge of Drupal is limited so I'm not even sure of the exact area where my problem is. I'm looking for pointers in the right direction so I can do more research on my own for an answer.

The Original Situation

I have two domains - let's call them example.com and example.net. The site was originally built for example.net and it is hosted at BlueHost with the following folder structure:

/root
    /public_html
        /drupal
            ... standard Drupal folders
            /sites
                /all (this is where all my site files are)

So basically, the entire Drupal installation is in a subdirectory of public_html. I can access URL's such as http://example.net/contact with no problem. So far, so good.

The Wrinkle

Where it starts to get complicated is when we bought example.com. As the primary domain, it points towards /root/public_html. So, I dusted off my Apache skills and fashioned an .htaccess file to redirect .com to .net, like so:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteCond %{REQUEST_URI} !^/drupal/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /rings/$1 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(/)?$ drupal/index.php [L]

The Problem

Now, if I go to http://example.com/contact, it does come up with a Drupal page, so I know that the rewrite rules are working. However, I get a page that says that The requested page "/contact" could not be found.

I want users to be able to use either domain. That is, http://example.com/contact and http://example.net/contact should go to the same page. So this is where I'm stuck. I'm not even sure where the general area of the problem is. Do I need to set up a multi-site configuration? That doesn't sound right because I'm only running one site. Is it something to do with the domain access module? That sounds more like something to run multiple sites of one Drupal installation. Any pointers at all will be greatly appreciated. Thanks in advance!

  • What is your objective? – AgA Feb 26 '14 at 6:23
  • Sorry, I guess I made it more confusing by using example.com and example.net. They are both alternate domains for the same site, so I want users to be able to use either domain. That is, http://example.com/contact and http://example.net/contact should go to the same page. – T Nguyen Feb 26 '14 at 12:37
0

If you're on Cpanel just point both domains to same siteroot folder.

Otherwise create a symbolic link of folder2 to folder1 where folder1 and folder2 and siteroots of each domain.

  • Well first of all, I've already "pointed" the .com domain towards the drupal folder using Apache RewriteEngine. This is working, as already stated. So, http://example.com/contact is being correctly rewritten as http://example.com/drupal/contact but Drupal doesn't want to server that page. – T Nguyen Feb 26 '14 at 14:14
  • Pl. re-read my answer. – AgA Feb 26 '14 at 14:19
  • If I'm missing something, can you clarify? Please refer to my directory structure above. .com is hosted in /public_html and .net is hosted in /public_html/drupal. I can't change /public_html to a symlink. I could create another subdirectory such as /public_html/drupal2 as a symlink of /public_html/drupal but I don't see the point of that. The browser is already being redirected to /public_html/drupal. – T Nguyen Feb 26 '14 at 16:29
  • Assuming /public_html/drupal2 contains the Drupal install. Just go to /public_html and give command: ln -s /public_html/drupal2/* .;ln -s /public_html/drupal2/.* .; – AgA Feb 26 '14 at 16:53
  • Without doing/changing anything more it should work. I've already used this setup. – AgA Feb 26 '14 at 17:04
0

Your rewrite may be overly complicated. Try this:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.net$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

This should happen before any of the Drupal code in .htaccess

Ideally, this should go in your apache config file.

  • Am I understanding it correctly that your Rewrite rules would redirect .net URL's over to .com? This isn't the solution the client wants, which is to keep both domains and have them access the same pages. So, http://example.com/contact shouldn't change the URL to http://example.net/contact but rather keep the .com URL and still work. – T Nguyen Feb 26 '14 at 16:24
  • Yes, one domain would be your main domain and the other would redirect. This is good for SEO purposes. – Scott Joudry Feb 26 '14 at 17:56
  • Yeah, I proposed that solution to the client but he didn't like it. – T Nguyen Feb 26 '14 at 18:13

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.