OllieMackJames Posted April 23, 2013 Share Posted April 23, 2013 How can I redirect to a page outside PW? I have tried the following: - I made a field called redirect with type=url - I also made a redirect.php template with the following code: <?php $session->redirect($redirect); ?> Then I made a page called Log In that uses template redirect I set the redirect field to : http://www.domain.com/desired-page-outside-pw.html When I view the page I get this error: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Any ideas how to do this? Link to comment Share on other sites More sharing options...
kongondo Posted April 23, 2013 Share Posted April 23, 2013 Could Apeisa's module be of help? This module adds page to Admin -> Setup -> Redirects where you can add 301 redirects (inside your site or to other domains). Link to comment Share on other sites More sharing options...
Radek Posted April 23, 2013 Share Posted April 23, 2013 Hi, i made quick test and redirecting outside PW working good. For quick test put this code at begining of your home template. $url = "http://www.google.com"; $session->redirect($url); 2 Link to comment Share on other sites More sharing options...
OllieMackJames Posted April 23, 2013 Author Share Posted April 23, 2013 Could Apeisa's module be of help? Thanks for the reply, tried that as follows: I made a page /log-in/ so it appears in the menu I redirected /log-in/ to http://www.domain.com/target-url.html But it does not work, it now shows the pw page for /log-in/ Radek, thanks, have not tried your solution yet, do not see yet how to include this in the menu, but will try. Hi, i made quick test and redirecting outside PW working good. For quick test put this code at begining of your home template. $url = "http://www.google.com"; $session->redirect($url); Link to comment Share on other sites More sharing options...
teppo Posted April 23, 2013 Share Posted April 23, 2013 Thanks for the reply, tried that as follows: I made a page /log-in/ so it appears in the menu I redirected /log-in/ to http://www.domain.com/target-url.html But it does not work, it now shows the pw page for /log-in/ This just means that everything worked as expected; Redirects module doesn't do redirect if PW page with that URL exists (it only does redirect when 404 is encountered), so when using it you shouldn't create matching page.. try removing it and redirect should work How can I redirect to a page outside PW? I have tried the following: - I made a field called redirect with type=url - I also made a redirect.php template with the following code: <?php$session->redirect($redirect);?>Then I made a page called Log In that uses template redirect I set the redirect field to : http://www.domain.com/desired-page-outside-pw.html When I view the page I get this error: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Any ideas how to do this? There's a slight problem in your code; it would seem that you're using (probably undefined) variable called $redirect instead of $page->redirect (redirect property of $page object, ie. the value of redirect field.) If your intention was to use value from field called "redirect", try this instead: <?php $session->redirect($page->redirect); 3 Link to comment Share on other sites More sharing options...
OllieMackJames Posted April 23, 2013 Author Share Posted April 23, 2013 Teppo, thanks, will give that a try. For now I got Radek's solution working. I only need this one redirect so just made one extra template for this, without adding an extra field. The url is now hard coded like Radek showed. Radek thanks again! 1 Link to comment Share on other sites More sharing options...
wishbone Posted April 27, 2013 Share Posted April 27, 2013 There's a slight problem in your code; it would seem that you're using (probably undefined) variable called $redirect instead of $page->redirect (redirect property of $page object, ie. the value of redirect field.) If your intention was to use value from field called "redirect", try this instead: <?php $session->redirect($page->redirect); with the above approach of OllieMackJames, this is the solution I needed to link to an external page inside MarkupSimpleNavigation menu. Thx! Link to comment Share on other sites More sharing options...
bfncs Posted May 12, 2013 Share Posted May 12, 2013 Edit: somehow I overlooked, that teppo already found the exact same thing ages ago... Don't mind, I just have to (!) get something done with Typo3 and try to make it standable by surfing through the Processwire forums... While directly linking to the URL in your menu is certainly the better idea, I think you just have a small error there: How can I redirect to a page outside PW? I have tried the following: - I made a field called redirect with type=url - I also made a redirect.php template with the following code: <?php $session->redirect($redirect); ?> Should have been: <?php $session->redirect($page->redirect); I've been using this approach for quite a long time without any problems. It's nice if you want to provide a link to an external URL that may change over time. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now