4 Replies Latest reply on Oct 4, 2012 4:42 AM by shin4649

    Redirecting page

    shin4649

      I am using the redirect option in page properties to redirect pages but the page just displays

      "This page redirects to <Page Name>" in publisher mode.

       

      Why is it not working?

        • 1. Re: Redirecting page
          kasq Level 3

          Hi,

           

          Probably when you wrote your custom code you didn't copy something from the main page component from libs.

          Try to check if in your custom component related to page template in which you wants to use Vanity URL attribute you haveat the begining

           

          <%

              // read the redirect target from the 'page properties' and perform the

              // redirect if WCM is disabled.

              String location = properties.get("redirectTarget", "");

              // resolve variables in path

              location = ELEvaluator.evaluate(location, slingRequest, pageContext);

              if (WCMMode.fromRequest(request) != WCMMode.EDIT && location.length() > 0) {

                  if (WCMMode.fromRequest(request) != WCMMode.PREVIEW) {

                      location=location.replace("/content/unicreditgroup/","/");

                  }

                  // check for recursion

                  if (!location.equals(currentPage.getPath())) {

                     response.sendRedirect(request.getContextPath()+location+".html");

                  } else {

                     response.sendError(HttpServletResponse.SC_NOT_FOUND);

                  }

                  return;

              }

              // set doctype

              currentDesign.getDoctype(currentStyle).toRequest(request);

          %>

           

          This is a little customized version of checking redirect attribute and redirects should works for a page which it is open only in the preview mode in author.

           

          I hope that this helps you.

           

          Regards,

          kasq

          • 2. Re: Redirecting page
            shin4649 Level 1

            THANKS!

             

            Works well now except for the docstyle. I did include file "com.day.cq.wcm.api.designer.Design" but still getDoctype not define.

            • 3. Re: Redirecting page
              kasq Level 3

              Hi,

               

              Try to import com.day.cq.commons.Doctype in the jsp and also add <cq:defineObjects/>

               

              kasq

              • 4. Re: Redirecting page
                shin4649 Level 1

                Everything was working fine but suddenly, I got this error:

                 

                response already committed (500)

                 

                not sure what is the problem now.

                 

                 

                 

                 

                Note: Problem solved. Redirect.jsp has to be executed first before anything else.

                 

                Message was edited by: shin4649

                1 person found this helpful