SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Page URL

  1. #1
    SitePoint Guru okrogius's Avatar
    Join Date
    Mar 2002
    Location
    US
    Posts
    622
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Page URL

    I'm having a page availible at http://www.domain.com/folder/ and http://folder.domain.com/

    What javascript can I place in the page to redirect to folder.doamin.com if it's being accessed via domain.com/folder/?

    Thanks in advance.

  2. #2
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can use PHP, enter the following line inside the index.php file located in domain.com/folder:

    PHP Code:
    <?
    header
    ("Location: http://folder.domain.com");
    ?>
    or if you're using ASP,

    <%
    Response.Redirect "http://folder.domain.com"
    %>

    Can't remember the asp one coz I haven't done ASP in a long time

    Don't know how to do it in Javascript though

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dragonhawk's answer is good - however i don't believe it actually uses Js, which was really the question.. wasn't it.

    If you DO really want to use js then something like:

    Code:
    <script language="Javascript">
    if (location.href.match(/domain\.com\/folder/) location='folder.domain.com';
    </script>
    Hope this helps... but if you can do it server side, then do.

    And dragonhawk - you forgot perl - naughty naughty

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •