Jump to content

[SOLVED] Redirect root of website


alexwest

Recommended Posts

Hi all,

 

Need some help setting up redirect rules for a specific configuration.

 

I have two websites under the same apache server, domain1.com in the root directory and domain2.com in root/domain2 as an add-on domain. The first website has three language versions each one in its own directory root/lang1, root/lang2, etc. and there are no files in the root directory for domain1.com. What I would like is to have a rule that redirects an access to www.domain1.com to www.domain1.com/lang1.

 

I have tried to set this up with simple 'Redirect' rules but the problem is that a redirect of the root directory affects both domains, ie both www.domain1.com and www.domain2.com are redirected to www.domain1.com/lang1.

 

Can anyone suggest how to set this up through .htaccess so I can get domain1.com to go to domain1.com/lang1 and keep domain2.com at domain2.com.

 

Many thanks in advance.

 

Cheers,

Alex

 

Link to comment
Share on other sites

Solved this problem using another solution than mod_rewrite but thought to post it here anyway for reference.

 

I placed an index file index.php in the root directory that redirects the traffic coming in through the main domain to the desired sub-directory. This did not affect traffic coming to the add-on domain, solving my previous problem.

 

These are the contents of the index file:

<?php

header("HTTP/1.1 301 Moved Permanently");

header("Location: ./lang1/");

exit;

?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.