Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Redirect Page

  • 28-03-2006 10:04am
    #1
    Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭


    Ok My brain is on a "no work please" day......

    Simple problem I would have thought. I have 2 domains pointing to the one website.

    I want domain2.com to redirect to a file if you go to domain2.com.

    i.e. www.domain2.com redirect to domain2.com/file.htm

    However, if someone comes into www.domain2.com/anything/, they shouldn't be redirected. "anything" is a number of different folders that are already created n the server.

    Domain1.com should not be affected at all, that shouldn't be redirected.

    I've tried a few things with mod_rewrite, but can't seem to get it going!

    Thanks in advance!
    Tom


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    You need to use a script as your DirectoryIndex, and check the HTTP_HOST in that. For PHP, it would be something like:

    [php]if (preg_match('/^(www\.)?domain2\.com$/', $_SERVER)) {
    header('Location: file.htm');
    } else {
    // Default action for domain1.com
    }[/php]


  • Registered Users, Registered Users 2 Posts: 706 ✭✭✭DJB


    I agree with Ken. If you're on a windows server, the asp code would look like:

    <%
    if instr(request.servervariables("HTTP_HOST"),"domain2.com") > 0 then
    response.redirect("somefile.htm")
    end if
    'normal page gets processed if it's domain1.com
    %>


  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    Ok sorry - I left out an important piece of information (Told you my brain was on go slow)

    The sub directories (i.e. domain2.com/whatever/) do an fread of the main file (i.e. index.php) - which means using script like this isn't possible.

    Unless, you can write me more code to check that if they are in a directory, don't redirect? :)


Advertisement