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

Per-page redirection in IIS7

  • 06-01-2013 12:42pm
    #1
    Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭


    I am tweaking the FeetFirst.ie web site. I had to redirect 3 pages to 3 different internal urls e.g.
    http://www.feetfirst.ie/page.aspx?pageid=592 -> http://www.feetfirst.ie/page.aspx?subsectionid=634

    The hosting company's knowledge base says that ISAPI Rewrite 3 is installed which means that it uses .htaccess and that the rules are interchangeable with Apache's mod_rewrite.

    I tried the following but it did not work:
    RewriteEngine on
    
    Redirect 301 /page.aspx\?pageid=592 http://www.feetfirst.ie/page.aspx?subsectionid=634
    Redirect 301 /page.aspx\?pageid=593 http://www.feetfirst.ie/page.aspx?subsectionid=619
    Redirect 301 /page.aspx\?pageid=594 http://www.feetfirst.ie/page.aspx?subsectionid=62
    

    The hosting company would not help. They would only confirm that ISAPI Rewrite was enabled on the server.

    I ended up implementing it in the C# files but I am not happy with this solution (this was hacked into existing code in the page.aspx file):
    <script runat="server">
        int GetParameter(string Name)
        {
            try
            {
                return int.Parse(Request.Params.Get(Name));
            }
            catch
            {
                return 0;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int SectionID = GetParameter("SectionID");
                int SubSectionID = GetParameter("SubSectionID");
                int PageID = GetParameter("PageID");
    
                // Redirect some pages to others, based on code from: http://www.rapidtables.com/web/tools/redirect-generator.htm
                // Redirect Mizuno 5k Winter Series left menu page to section in black menu.
                if (PageID == 592) {
                  Response.Status = "301 Moved Permanently";
                  Response.AddHeader("Location","http://www.feetfirst.ie/page.aspx?subsectionid=634");
                  Response.End();
                }
                // Redirect Good Friday Run left menu page to section in black menu.
                if (PageID == 593) {
                  Response.Status = "301 Moved Permanently";
                  Response.AddHeader("Location","http://www.feetfirst.ie/page.aspx?subsectionid=619");
                  Response.End();
                }
                // Redirect Killarney Women's Mini Marathon left menu page to section in black menu.
                if (PageID == 594) {
                  Response.Status = "301 Moved Permanently";
                  Response.AddHeader("Location","http://www.feetfirst.ie/page.aspx?subsectionid=628");
                  Response.End();
                }
            }
        }
    </script>
    

    What am I doing wrong in .htaccess?
    Is there a super simple test that I can add to .htaccess to confirm that ISAPI Rewrite is enabled and working?


Advertisement