manlio Posted August 11, 2014 Share Posted August 11, 2014 Hi, I'm try to develop a front end area and I have a little problem. I'm on windows 8.1 and I use Wamp server. When I use a redirect with short syntax like this $session->redirect('/profile/'); bring me to localhost/profile and doesn't find the page If I use page syntax everything is working: $session->redirect($pages->get("/profile/")->url); bring me to localhost/Processwire/profile I would like to use the first easiest way. Can you help me? Thanks Link to comment Share on other sites More sharing options...
marcus Posted August 11, 2014 Share Posted August 11, 2014 Hi, I'm try to develop a front end area and I have a little problem. I'm on windows 8.1 and I use Wamp server. When I use a redirect with short syntax like this $session->redirect('/profile/'); bring me to localhost/profile and doesn't find the page If I use page syntax everything is working: $session->redirect($pages->get("/profile/")->url); bring me to localhost/Processwire/profile I would like to use the first easiest way. Can you help me? Thanks The first way may be shorter, but it isn't correct if you want to redirect to the page that has the path /profile/. In this case, the redirect() method does not expect a "ProcessWire Page Path", but simply does what you ask it to do, redirecting to [root]/profile. As if you would create a link: <a href="/profile/">Foo</a> 2 Link to comment Share on other sites More sharing options...
manlio Posted August 11, 2014 Author Share Posted August 11, 2014 Thank you Marcus. I'm using code by Ryan so I was thinking was a good practice https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919. Anyway how I can set in the right way the root in Processwire? Because also links point to localhost/profile instead of localhost/Processwire/profile Thank you agian Link to comment Share on other sites More sharing options...
arjen Posted August 11, 2014 Share Posted August 11, 2014 The problem is the folder and the relative urls. $session->redirect('/profile/'); This redirects to a page directly under root. For example: this code will redirect to http://manlio.com/profile/. A ProcessWire url knows where the page is located (including if it's installed in a folder). So: $session->redirect($pages->get("/profile/")->url); Will redirect to http://manlio.com/Processwire/profile/. 2 Link to comment Share on other sites More sharing options...
Soma Posted August 11, 2014 Share Posted August 11, 2014 The root url $config->urls->root (including subfolders or if none it returns "/") So $session->redirect($config->urls->root . "profile/"); 1 Link to comment Share on other sites More sharing options...
manlio Posted August 11, 2014 Author Share Posted August 11, 2014 Thank you to everybody. You are really helpful and fast. I used $config->urls->root syntax for my links. 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