Wordpress “Page Redirect” template
Have any page in the Wordpress "Pages" list invisibly redirect to a static page or other url
Posted on Wednesday, February 20th, 2008 at 2:43 pm
The very nature of Wordpress demands that you work within it's infrastructure in order to maintain flexibility. Sometimes, though, the structure of your pages demand that you need to operate outside of this constraint.
This template lets you specify a single URL as the page content, then as the page loads, the template automatically redirects the page to this new location.
Usage
Once you've uploaded the template-redirect.php file to your themes directory...
1 - Create a new Page in your Wordpress control panel
2 - In the Page Content panel, just enter the URL (or local path) you want to redirect to:

3 - Set the Page Template dropdown to "Page Redirect":

That's it!
Examples
Examples of URLS might be:
- category/flowers (a relative link to the permalink for "flowers")
- ../page.html (a page outside of a Wordpress subfolder (the WP folder being /blog/) but still in your site)
- http://www.davestewart.co.uk/resources/ (a page on a completely different site)
The "Latest developmentsā¦" page in my sidebar automatically redirects to /category/development/ - or in other words, the archive for my "Development" category, as my home page is not the standard "last-post first" format.
OMG You are a lifesaver. I’ve litterally spent 20 or 30 hours trying to figure out ways to do this. I even starting learning PHP. I am NO programer just a basic techy. Might site is not ready yet because I was waiting to figure this out. If you find out a non-hacked way to do this PLEASE let me know. Now I have to get on design and layout, not to mention other stuff.
Again, THANK YOU!
Alexander
Hey Alexander,
I’m glad it’s working for you!
I’m not sure what you mean by “non-hacked” though? If you mean you want a solution that works solely within the core Wordpress functions, then I don’t know, to be honest. As far as I can tell in my limited usage of Wordpress (ie, this blog) and the woefully-incomplete help, “page”s and “post”s are just database entries - that’s just how Wordpress works, so the management of static content falls outside this paradigm (and thus “hacks” like this).
Came across this searching Google for a method to redirect pages to categories

I guess this is the best way ever to do it. Thanks a ton, Dave. And a nice blog
nice clean solution…using pure Javascript in the source of the page has a visible “hiccup”. thx !
Thanks greatly for this!!! This is exactly what I have been looking for. One more obstacle on my list taken care of by the wonderful wordpress community. Kudos.
Thanks for the thumbs-up, chaps!
I would just like to say… Thank you.
Hey,
One small problem - after installing the template and setting up two redirects, my site no longer gives out “404 - Not found” errors. All it does when someone types a wrong URL is point them to the first redirect I set up. You can try and see for yourself.
Any idea why this could be?
Thanks,
Sebastian
Hi Sebastian,
Well that’s strange, because all the page does is grab the text from the post content, and redirect the page to the new location; it’s really very uncomplicated, so I don’t really see how it could affect your 404 page.
What happens if you remove the template links?
doesn’t work. i followed the directions–created a new Page, included the redirect URL as the only content, Saved and Published.
i’m trying to redirect incoming traffic from a page that was deleted to my main page, by the way. so that when they click a link, they bypass the error result from a deleted page and go right to the Home page.
cheers,
-james
Hi James,
What was the exact URL you placed in the content area?
http://www.mydomain.com
just like that (with “mydomain” replaced with a real one, of course.)
Hmm. Not sure why it’s not working for you, as it does here. To test, I’ve added a new page to my top links, “Dave Stewart”, and that’s just “http://www.davestewart.co.uk”, and it works fine. Check it out, as I’ll delete it in a day or so.
Another option you could use would be to add an Apache Redirect Directive to an .htaccess file in your root directory, which would redirect traffic at the server level, rather than the page level: http://www.base64.co.uk/apache-redirect-directive/
And if you want to email me, feel free.
Neat trick. My only suggestion is that $HTTP_SERVER_VARS is, I believe, deprecated in PHP 5. People should be using $_SERVER. I made this modification and it works fine.
Thanks, though. This is way simpler than the Redirect plugin I found.
Cool. Thanks Ethan - I’ve updated it now
hi. it works great, 1 question from me:
Is it possible to redirect the page to an alternative site IN a new windows?
1000 thanks
looking for solution that i type my url and is redirected to new static page
and how it can be done from the post…. is their anyway to do from post
thankyou and looking forward for your prompt reply
Hi Murtaza,
Sorry - I can’t help you there! Page Redirect does one thing and one thing only.
Cheers, Dave
Here is an even simpler solution. If your permalink options are not set to the default option, just make the permalink the link that you want the page to be redirected to. I don’t know how deep you can go but it’s worth a shot.
Awesome. Thankyou very much
I think (just for searchbots happiness) it would be better add a 301 header before redirect:
// do the link
—–> Header(”HTTP/1.1 301 Moved Permanently” );
Header(”Location: $link”);
die(”);
thanks a lot for your page-redirect-template. It solved my need in just one second!
After trying two plug-ins that seemed either buggy or complete overkill I stumbled upon this page and find a 1-minute fix for my problem. Brilliant - thanks!