Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple Page re-direction

  • 01-02-2006 04:47PM
    #1
    Registered Users, Registered Users 2 Posts: 224 ✭✭


    Hi,

    Anybody know a quick bit of code to redirect one web page to another. e.g.

    I click on a link page1.asp and goes reads a bit of code in page1.asp and instantly brings me to page2.asp.

    ???


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Hi,

    Anybody know a quick bit of code to redirect one web page to another. e.g.

    I click on a link page1.asp and goes reads a bit of code in page1.asp and instantly brings me to page2.asp.

    ???

    Something like this maybe?
    <%
    If Request.QueryString("action") <> "" Then
        'Do your code thing here
        Response.Redirect("page2.asp")
    End If
    %>
    <html>
    ...
    <a href="page1.asp?action=true">Click here to carry out the action</a>
    ....
    </html>
    

    Edit:

    I am presuming that by "read a bit of code" you mean there is some ASP code that you need to run? Otherwise, why wouldn't a link work?


  • Registered Users, Registered Users 2 Posts: 632 ✭✭✭ButtermilkJack


    <meta http-equiv="refresh" content="5; URL=http://new_web_page"&gt;

    Don't know anything about 'asp' but I'm sure the principle is the same.


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Sorry guys, I meant an automatic re-direct. This is a little complicated to explain. Basically I have a dedicated server which host a site for me e.g. site1. Thats well and good but I have another site (site2) that is contained within the site1 folder, this is because of the firewall redirect. I have tried everything to try and keep these sites away from each other but unfortunately I cant. So I think this might be the best way just to have an automated redirected page which will kick the user back out of the current sites (site1) using something like ../../site2/home.asp.

    Does this make sence to you...probably not...it does in my messed up noodle...


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Sorry guys, I meant an automatic re-direct. This is a little complicated to explain. Basically I have a dedicated server which host a site for me e.g. site1. Thats well and good but I have another site (site2) that is contained within the site1 folder, this is because of the firewall redirect. I have tried everything to try and keep these sites away from each other but unfortunately I cant. So I think this might be the best way just to have an automated redirected page which will kick the user back out of the current sites (site1) using something like ../../site2/home.asp.

    Does this make sence to you...probably not...it does in my messed up noodle...

    Sorry, I can't really make out what you are trying to do. Do you want to redirect people based on the URL or something?


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Sorry confusing myself too

    This is the way my sites are set up.

    inetpub/wwwroot/site1/home.asp
    inetpub/wwwroot/site1/site2/home.asp

    I would preferably like to have it like so

    inetpub/wwwroot/site1/home.asp
    inetpub/wwwroot/site2/home.asp

    Now what i plan on doing is when you hit the link to go to
    inetpub/wwwroot/site1/site2/home.asp

    you are redirected to
    inetpub/wwwroot/site2/home.asp

    Do you understand this a bit better


  • Advertisement
  • Subscribers Posts: 9,716 ✭✭✭CuLT


    Create a file called ".htaccess" in /site1/site2/

    In that file, place the line:
    Redirect /site1/site2 http://www.site1'sdomain.com/site1
    

    That should redirect any requests for anything under site2 to be mapped to its counterpart in site1.


  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Sorry confusing myself too

    This is the way my sites are set up.

    inetpub/wwwroot/site1/home.asp
    inetpub/wwwroot/site1/site2/home.asp

    I would preferably like to have it like so

    inetpub/wwwroot/site1/home.asp
    inetpub/wwwroot/site2/home.asp

    Now what i plan on doing is when you hit the link to go to
    inetpub/wwwroot/site1/site2/home.asp

    you are redirected to
    inetpub/wwwroot/site2/home.asp

    Do you understand this a bit better

    OK, sounds easy enough.

    Easiest thing to do is put the following line:
    <% Response.Redirect("/site2/index.asp")%>
    
    at the top of /site1/site2/index.asp

    You could also do a custom 404 page for the /site1/site2/ that goes to /site2. The advantage of this is that it will cover any pages in the site1/site2 folder that someone may try to go to (e.g. if they have a specific page bookmarked).

    If you have access to the IIS admin console, there are probably other ways of doing it there as well.


  • Registered Users, Registered Users 2 Posts: 4,003 ✭✭✭rsynnott


    CuLT wrote:
    Create a file called ".htaccess" in /site1/site2/

    In that file, place the line:
    Redirect /site1/site2 http://www.site1'sdomain.com/site1
    

    That should redirect any requests for anything under site2 to be mapped to its counterpart in site1.

    He's using IIS.


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    rsynnott wrote:
    He's using IIS.
    *Smacks forehead*

    Gah, what a schoolboy error :/


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Unfortunately that doesnt work, I cant get it to redirect outside

    inetpub/wwwroot/site1

    to

    inetpub/wwwroot/site2

    I have tried your response.redirect method with various combinations e.g.

    <% Response.Redirect("../../site2/home.asp")%>
    or
    <% Response.Redirect("../../../site2/site1/site2/home.asp")%>

    But no luck...any ideas


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Unfortunately that doesnt work, I cant get it to redirect outside

    inetpub/wwwroot/site1

    to

    inetpub/wwwroot/site2

    I have tried your response.redirect method with various combinations e.g.

    <% Response.Redirect("../../site2/home.asp")%>
    or
    <% Response.Redirect("../../../site2/site1/site2/home.asp")%>

    But no luck...any ideas

    You should have no problems redirecting from one folder to another.

    I don't know if it will cause a problem, but you don't need to include inetpub/wwwroot in the paths. If IIS is set up with the default settings then inetpub/wwwroot is just treated as the root folder.

    So you don't redirect to
    inetpub/wwwroot/site1
    You redirect to
    /site1

    So, if you want /site1/site2/home.asp to automatically go to /site2 (inetpub\wwwroot\site2\home.asp)
    Then I don't see why the following won't work
    <%
    Response.Redirect("/site2/home.asp")
    Response.End
    %>
    This should go at the top of site1/site2/home.asp

    Are you getting any error messages?


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Ok,
    I getting an error. i.e. You have not got sufficient rights to view this page. Which is good because now at least i know Im hitting the site...


Advertisement