Peter Knight Posted May 24 Share Posted May 24 I've been looking at various Redirect Modules and I don't think my current requirement is possible with any of them. I want to enter a PageID (my source page) and create a 301 redirect to a different URL (destination). Normally you might do this in the htaccess file with page paths but I'd rather do something within PW itself. Jumplinks comes close to supporting this but doesn't support page IDs. The reason I need page IDs to be specified in the source and destination is that my client often updates the page path for SEO experiments etc. If I were to use page Paths as the source and destination, they might stop working. Link to comment Share on other sites More sharing options...
BitPoet Posted May 24 Share Posted May 24 It's pretty easy to implement that without a module. Create a page reference field and add it to all applicable templates. Let's call it 'redirect_page'. In your prepend template file, add a little snippet of code that checks if redirect_page is set and issues the redirect if it is. <?php if($page->redirect_page) $session->redirect($page->redirect_page->url); 1 Link to comment Share on other sites More sharing options...
Peter Knight Posted May 24 Author Share Posted May 24 Thanks BitPoet. I had that setup but wasn't sure it was using a 301 redirect method for SEO. I also have a nice page created via ListerPro which lists all the redirects I have made. Handy for an at-a-glance view etc Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 27 Share Posted May 27 On 5/24/2023 at 11:41 AM, Peter Knight said: The reason I need page IDs to be specified in the source and destination is that my client often updates the page path for SEO experiments etc. If I were to use page Paths as the source and destination, they might stop working. What about the core module Page Path History? It takes care of page URLs in case they change and redirect from old to new URLs. ProcessWire is quite good at managing old URLs, at least for those created in your ProcessWire instance. In case of a migration it's something totally different. There is even a managing area under the settings tab in each page. There would be no real need to add redirects anymore. Unless you want to use something that never existed before. 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