Search the Community

Showing results for tags 'redirect'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 41 results

  1. Hello I need some help with redirecting. I have create a template called (redirect) and AssistedURL field called (redirect_link) for redirecting a page if necessary. In template I've added: <?php if($page->redirect_link) $session->redirect($page->redirect_link); ?> redirect is working, but is it possible to create a link non clickable also, maybe with placing # for link? If I place # now it gives the whole link of the site with /# at the end and gives blank page. So placing (#) would disable a link totaly or something. Hope u understand what I mean Thank you R
  2. Sometimes I need pages in the site tree that are basically just a reference to another page – to redirect to the original page or display the same content under the new page url. I was surprised I couldn't find anything like that in the forum or as a module already. However, there is a new module by @Robin S but not exactly what I need. Example Home News Press Newsroom Media Services About Newsroom (virtual page for /news/newsroom/) Contact Example I: The page /about/newsroom/ should act as /news/newsroom/ – so, wehen I loop all pages for a sitemap both pages should have the URL /news/newsroom/. Example II: Another example (not often used) would be tu display the exact same content on /about/newsroom/ – although the page itself has no content on its own. Those examples don't have much in common, but they are just virtual or fake pages in the site tree. While the second one should be an easy task with wireRenderFile(), the first example isn't quite obvious to me. I think I have to use hooks and I have no idea where to start. I really appreciate you guys come up with a solution for everything, but I need to learn this myself So just some hints to start would be great! Do I put the code into a module or some of the _init.php, ready.php etc. files? Or do I have to use a template file (e.g. virtual-page.php)? When I look into Captain Hook – how do I find the appropriate point to hook into? (/wire/core/ Page.php and loaded()?) Do I need to create/manipulate each field separately (path, title, summary)? Sorry for the long read
  3. I have a single Processwire install with two domains pointing to it. There's which is the "proper domain" and won't be live for a few months which needs to go live immediately but just point to a sub-page Is there a way with .htaccess to know when the site is being accessed through, keep that address is the browser bar and redirect to To give a little context, a part of the in-progress needs to be accessible immediately and we've registered that temporary and pointed it at the same site. The key here is to only do that redirect when is the source request. Otherwise I guess I'd use Jumplinks etc
  4. I am trying to make a simple wiredata module that lets me select a page I want all visitors to be redirected to. I have this working in ready.php but then I decided on putting it in a module and I can't get it to work. Here's the relevant bits: public function ready() { $this->addHookBefore('Page::render', $this, 'redirectUsers'); } public function redirectUsers(HookEvent $e) { $page = $e->object; // The page we want to redirect to. $redirect = $e->pages->get($this->redirectPage); if ($page->id == $redirect->id) return; // Prevent infinite loop. if (!$e->user->isLoggedin()) { $e->session->redirect($redirect, false); // 'false' indicates 302 temp redirect. } } I left some checks out for simplification. Whenever I'm not on the page that I want to redirect to, an infinite redirect loop starts. Could anybody explain why that is?
  5. Like title says i've some domains with umlauts öäüß and i'd like to redirect them to the non umlaut version example: http://my-domä to i've somethings like this in my htacess: ##redirect umlautdomain (not my domain) RewriteCond %{HTTP_HOST} ^xn--mhldorf-nsb.d$ [NC] RewriteRule ^(.*)$$1 [R=301,L] in my config.php i only have in my hosts list... is there something that i've misunderstood? so far it doesn't work....but may the htaccess rules take some time to exicute...i tried since about an hour some different rules. regards mr-fan
  6. I hope this is the correct place to post this. I currently am building a "dashboard" that displays some stats etc, but also handles login/logout with a form. Currently, when a user uses the form on the homepage, they redirected (if the credentials are correct) to the backend of processwire. However, I was hoping to direct the user back to the dashboard and display an alert (for now until I get a library to handle this). I got it somewhat working if I dont redirect the user. However, if I refresh the page, the alert still "pops up". Does anyone know of a way to redirect to the home page, but then display an alert? My Code to login: <?php if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($dash); } } ?>
  7. Hi Everyone I have a problem here. I have built a site with Processwire on localhost and then transferred to my customer's server. a) it's a windows server (unfortunately) and b) there is a domain-mapping for this site, the domain points to a folder of another domain. Sorry, I can't explain it any better, I don't really understand the different types of servers (why do they have to be different anyway...). My problem is, that I see the main website but not the admin page. Do I have to add anything to my .htaccess file? I also tried to include web.config file. Not .htaccess nor web.config file have an impact when changing its content. I really have no clue what to do!! Links:, Thanks for any pointing in the right direction!
  8. The last days two new sites went online and both got a SSL certificate installed. But one has a HTTP problem, although both are configured the same (seem to be). When I run curl -I -L ( it gets redirected to itself again and again. I had a HTTPS redirect in my .htaaccess but have removed it. The home template was configured to use only HTTPS but is now configured to accept both. If I change that to HTTP only, I get and error. The origin must come from PW, because all files not processed by PW don't have the redirect problem. I had a look at the /site/assets/cache/ folder but don't know what to delete. And there is a cache table in the DB as well. Don't know either if I can just delete its entries. Apache 2.4.18 PHP 7.0.11 PW 3.0.42 No dedicated cache installed, no cache activated in PW
  9. Hey Guys! Im new to PW and am working on a website built on PW. Im trying to understand how sessions work in PW. Specifically what exactly is happening when session expires. The thing is that my client wants to be redirected to homepage whenever session expires, so basically he doesnt want to be redirected to admin login page when he's in the admin environment of PW(he doesnt want his clients to see the admin login page for whatever reason). Is it possible to hook to the session expiration and redirect to a specific url? And what is the correct way to do it in PW? I would appreciate the help! Cheers!
  10. Hi all, I'm creating a website for a magazine publisher. This will include a supplier section with press releases attached to company profiles. The idea is that companies can register and manage their profile and press releases (CRUD) via a dashboard. The dashboard is a Process module. Ben Byford's RedirectAdminPages module is being used to lock out the rest of the backend, with a few modifications. The following code should redirect every admin page to the dashboard page but still allowing logging out. However logging out just redirects to the dashboard page: // do not redirect if page matches: if($this->page->template != "admin" // any non-admin page || $this->page->is($this->redirectPage) // the dashboard page (prevent infinite loop) || $this->page->parent->is('/admin/login/') // various attempts to allow logging out || $this->wire("process") == 'ProcessLogin' || strpos($this->page->url, $this->wire('config')->urls->admin . 'login/logout') !== false ) { return; } // find roles set in module configuration and create array $roles = explode(',', $this->userRoles); // for each user in module config check to see if current user foreach ($roles as $key => $val) { // get a role from the roles array $roles[$key] = trim($roles[$key]); // if current user found with role then redirect if($this->user->hasRole($roles[$key])){ // redirect session to page stored in config $this->session->redirect($this->redirectPage); // code should never get here but this is a simple fallback break; } } } } I'm surprised that this URL matching doesn't work: || strpos($this->page->url, $this->wire('config')->urls->admin . 'login/logout') !== false Because this does work for allowing page edit: || strpos($this->page->url, $this->wire('config')->urls->admin . 'page/edit') !== false Any ideas? That issue aside, as a learning process I'm going to re-implement the dashboard as front-end pages. I guess that the advantage of using the ProcessWire back-end is most of the functionality is already there, you don't need to create forms and handle the processing, create / import css etc. So it'll be interesting to see how much of a difference this makes, and how much control each approach provides. I'd love to have some thoughts and feedback from those of you who've tried both methods? PS this will be my third website created with ProcessWire and it's already been a lot of fun, and as a CMS it 'just feels right', so a big thanks to Ryan and everyone who has contributed. Thanks
  11. Hi, I'm in the process of moving over some Blogger blogs into ProcessWire. We want the URL format to match what was in place previously, so which would be fine if we just created the posts at the root of the site. The issue is the fact that we have more than 500 posts, which we've setup in a /blog/ folder so as not to clutter the root of the site with a list of posts. I saw this mentioned in another post, but @ryan was not "not confident that PW will be totally happy with it". RewriteRule ^$ /subfolder [L] Is there a ProcessWire core team sanctioned way to rewrite all /subfolder/ URLs to the root? Thanks!
  12. I think you can create a simple logout link with <a href="admin/login/logout">log out</a> But it redirects to the login form in the admin area. Can I hook into logout and change the redirect? Default redirect home would make sense. Or is the way to do this still to create a logout template + page with session->logout() and a redirect?
  13. Hello, for quite a while I found it quite annoying that when you edit a page from a lister view and then save+exit you will end up at the page tree and not at the lister view where you came from. I haven't found a setting that lets you return to the lister view. I wrote a little hook that does just that for a project where I am using Lister Pro. The lister is called Events and has a fixed url. It lists only one type of pages with template event. Here's the working hook code that I placed in admin.php: // redirect to events list on save+exit wire()->addHookBefore('ProcessPageEdit::processSaveRedirect', function($event) { $id = (int) $this->input->post('id'); $page = wire('pages')->get($id); if($this->input->post('submit_save') == 'exit' && $page->template->name == 'event' && wire('user')->hasRole('member')) $this->session->redirect(wire('config')->urls->admin . 'events/'); }); Now I would like to make this more generic so that it works for any lister. How can I get the referring URL (other than from $_SERVER['HTTP_REFERER']) to use it instead of the hardcoded URL I have now in the redirect? And is there any way that I can access properties of the instance of ProcessPageEdit that called processSaveRedirect? The $event->object is the processSaveRedirect method and $this is ProcessWire. How can I access properties of ProcessPageEdit? E.g. $id or $page. ATM I am getting the page id from the $input->post. Obviously I am not a savvy PHP OOP dev and have no idea how to do such things in a proper way EDIT: I know I could open pages from the lister view in a modal to avoid having to redirect. But I don't want to use that option. $_SERVER['HTTP_REFERER'] gives me the URL of the page that I edited and not the URL of the lister.
  14. I have a VueJS single page app with a router, how do I redirect all requestes to the index.php page? The processwire .htaccess file is quite big I am not sure how to change it. This is what is suggested in the router docs: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>
  15. Hey all, things had been going well remapping a site from one domain to another, but hit a snag and have searched for hours and don't know how to continue. 1) I was moving everything from to 2) I moved every single path individually with redirects like this: Redirect 301 /category/post Everything smooth sailing until today when through webmaster tools (to say site address as moved) I had to execute "Redirect 301 /" -- now some of the urls go through and some don't include the / after the .com extension. For example: > no problem > no problem BUT a bunch of the URLs then don't push... For example: > http://www.dranthonygustin.comrecipe/paleo-jam/ (notice NO / after the .com extension) and > http://www.dranthonygustinwp-admin (which of course leads to dead link) There are a bunch of paths that do this, that I checked before and were working, such as: Redirect 301 /recipe/paleo-jam Any idea why after implementing the / redirect, why it broke some of the redirects and not all? Thanks!
  16. Good day. Short Version: How can I redirect a template that doesn't have a .php file back to its parent? ------- Detailed Version Question: I have a a template that doesn't have a php file. The template is basically used to hold other templates. For instance, I have a php file called business-directory.php which display's all (child) businesses from the business categories template. Business Directory business-categories (2) ABC Fence Roper Cattle So, if a user goes to /home/business-directory/ it fetches and displays all children from business categories. However, if someone manually types in /home/business-directory/business-categories/ I want to redirect them back to the parent 'business-directory'. (without having to create a .php file called business-categories.php) I was looking at the template settings for 'business-categories' and came up with what you see in the photo. I basically toggled off View Pages for guests to get the URL options, saved it, then toggled back on View Pages for guest (everyone) and it still retains the URL for the redirect. This below seems to work as long as the page is not moved. I tried putting in $page->parent->url;, but got an error that this was a 'Forged Request'. Any suggestions?
  17. Hi there, actually I found a solution but I'd like to know, whether there's a better way. PW is installed in a subdirectory /pw/. In root there's the site in pure HTML, which I set up first and then integrated it into PW. Images, CSS and other resources are in subdirectories on the same level as /pw/. Now, as the PW version runs flawlessly, I redirected the domain to the subdirectory, where PW took over. I did this with the provider admin panel, not with some .htaccess in the root directory. The result was, that, with the server replacing all "domain.tld" strings with "domain.tld/pw", all queries to resources ran not to "domain.tld/img/..." but to "domain.tld/pw/img/..." , which gave of course the 500 error. The solution was, to simply copy all resource directories, like /styles, /js, /images &c. into /pw. The more experienced may have a better card in their sleeves? I am interested.
  18. Hello, I need to redirect the old paths after migration to a multisite PW installation. There are 3 domains and small differences between paths i.e. old path: domain-2/?text new path: domain-2/text or domain-2/new_text I try it via .htaccess (in the root direction) with an 301 redirect: redirect 301 domain/old_path domain/new_path -> generates an 500 server error What is wrong? How to do that?
  19. Hi there, Goal: user profile visible as: So far visible as: 404 template: <?php $username=$input->get->user;?> <? $hello = $users->get($username); echo $hello->name; echo $hello->id;?> I have added this to .htacces RewriteRule ^[A-Za-z-]+/([A-Za-z0-9-]+)/?$$1 [NC,L] But it doesn't work. It would be much better to not use 404 template.. Any idea how to get this working? edit: I've added page and template "show" with the above code. I have added this code to <?/** * This hook modifies the default behavior of the Page::path function (and thereby Page::url) * * The primary purpose is to redefine blog posts to be accessed at a URL off the root level * rather than under /posts/ (where they actually live). * */ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'show') { $event->replace = true; $event->return = "/$page->name/"; } });?> Seems like I'm missing something as it doesn't work for me. And I can't access users path anyway as it's restricted, right?
  20. Hi. I have a membersite that sends out emails to users with links to specific pages. When the user clicks on the link in the mail and the browser opens the site, the user is redirected to the login page. However, I would like for the user to be redirected back to the page they opened from their mail. I don't see how this can be done in Processwire. I have a template and in the Access settings, I have chosen to redirect to the login page. There is on tag that I can include with {id}, but that returns the ID of the login page. I would like to have a tag that returns the ID of the original page the user has opened. Maybe a tag called {id_original} could be a way to solve it. Is there some other way I can filter the redirect process?
  21. Is there something wrong with the following redirect syntax ? <?php $session->redirect($page->get(1184)->url); ?> I've used this (below) to successfully redirect to a child URL so thought I was on the right track. <?php $session->redirect($page->child->url); ?>
  22. Hi there, I think it is a quite simple Question. My Page has 2 sections, and can be accessed by 2 Domains. It should automatically redirect to a section by domain How can I achieve the following setup:? -> -> Thanks for any help Joerg
  23. hi guys, I have a project which is about to get live and it has two languages: default: englisch second: german Unfortunatelly translation of content will not be done in English for the launch. How can I simply redirect EVERY person that is not logged in to the German version of a page? Once everything has been translated I will delete the redirect and everything should be fine. It would be great to have a redirect only for not logged in users so the editor can check how the site looks like when adding the translations. Any idea? thanks Sascha
  24. I moved an old site to processwire and want to redirect the old URLs with php-filenames to the new folders via .htaccess to match the new structure. I tried: RedirectMatch 301 /filename.php The Browser end up like this: Its interfering with that Processwire .htaccess rule # ----------------------------------------------------------------------------------------------- # Pass control to ProcessWire if all the above directives allow us to this point. # For regular VirtualHosts (most installs) # ----------------------------------------------------------------------------------------------- RewriteRule ^(.*)$ index.php?it=$1 [L,QSA] If i comment that out the redirect in the URL is ok, but every Klick on a websitelink is showing the homepage. Any idea how i can fix this? Thanks Andreas
  25. Hello, I've tried to search the forum for this but so far no luck so I decided to post this in wishlist section. Under the Templates/Permissions, there is an option to redirect the user to a certain URL when he is not permitted to view the page. However, this is a pure text input and it's really difficult in the case where I would like to choose to redirect user to a certain page. The page might have multiple URL (multiple languages) or the url might be changed later by the user so a static URL redirection here is no good. Have a nice day.