Jump to content

URI redirect


jasondrane
 Share

Recommended Posts

Hi Jason,

if you're doing it just for a few pages, you don't need any module/plugin; you can do this simply by using templates! :)

  • Create field 'redirectTo' – customizable, of course
  • Set that field to be 'single page', and select the inputfield you wish
  • Create template 'redirectPage' – again, custom :)
  • put following code in your template file
  • Create page that links to original page
  • you've made your virtual page

Code for your template:

<?php
/*
 * Template: redirectPage
 *
 * Used to redirect URL adress to other page with 301 HTTP code
 */
$session->redirect( $page->redirectTo->url );

I actually use this at least once each site.

  • Like 6
Link to comment
Share on other sites

Hi Jason,

if you're doing it just for a few pages, you don't need any module/plugin; you can do this simply by using templates! :)

  • Create field 'redirectTo' – customizable, of course
  • Set that field to be 'single page', and select the inputfield you wish
  • Create template 'redirectPage' – again, custom :)
  • put following code in your template file
  • Create page that links to original page
  • you've made your virtual page

Code for your template:

<?php
/*
 * Template: redirectPage
 *
 * Used to redirect URL adress to other page with 301 HTTP code
 */
$session->redirect( $page->redirectTo->url );

I actually use this at least once each site.

Thank you a MILLION times over, Adamkiss! That is exactly what I was trying to do! Cant wait to use it. This is my first project using processwire. I will post a link when its done!

Link to comment
Share on other sites

  • 2 years later...
  • 6 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...