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… sub-directory, i.e. wp-content/themes/theme_name/
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!
Note that in Wordpress 2.7 and later, you will need to do a little additional setup work to display the page template dropdown (don’t ask me why).
See this link for further details.
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.
Download
template-redirect.zip
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!
Your plugin is working great, but there’s one problem I’ve come across when trying to use it.
We’re using the Post Template Plugin, and I’m trying to point your plugin to redirect to a specific plugin we’ve made. This is the URL for the specific template:
http://www.thelocallanding.net/wp-admin/edit.php?page=post-template/includes/manage-templates-page.php&action=create-post&template_id=6
I’ve put that in the page to be redirected and set everything else accordingly (works fine with simpler links), but it seems that it will only redirect to
http://www.thelocallanding.net/wp-admin/edit.php?page=post-template/includes/manage-templates-page.php
leaving off the “&action=create-post&template_id=6″. This shows a list of all templates we’ve made with the Template Plugin, but I cannot for the life of me convince it to keep that vital last part of the URL which would lead directly to the specific template I want to redirect to.
I don’t know much about this type of thing, but if you can think of any way to persuade your plugin to keep the full url, I’m sure world peace wouldn’t be far behind!
Thanks for the plugin, and any help you can give on this issue.
Add another thanks to the pile!
This is perfect – and no hiccups!
I’m trying to use it for WP 2.7 and it doesn’t appear to be working. There is no section that allows me to choose page redirect on the “page” page.
Thanks! You just made my day
Hmmm…is there more to it? I uploaded the php file to my themes directory. But when I go to the template drop-down, the redirect option is not there. What can I do? I tried also uploading the redirect folder to my themes directory, with no luck. How’d everyone else get it to work? Are there limitations depending on which version of WP you have?
Great!
It also works with multiple languages (polyglot plugins)
DUDE! This rocks! Thank you so very, very much!
All I can say is great tip… It took me 5 hours to discuss with my host how to redirect one of my pages to my main site and he finally advised me to search google.. LOL.. Now I know my host still did a good job by giving me suggestion…
This is what I’ve been looking for thank you, because before I have to link within my page which is very inconvenient, the user has to click two times…thanks a lot!
This works great, thats for the help. Is there a way i can make this load a page in a new window rather than in the same window? Im a bit of a newb here and this script has helped a load. Thanks again.
This is why I always found geeks to be so sexy! Always love to see some brains! Big muaaahhh and thank you for the great solution!
Thank you. I have been trying to figure this out for a while now.
[...] Wordpress ‘Page Redirect‘ template [...]
Sorry to anyone who’s left comments asking for help over the past VERY long while, I’m not really giving the blog much attention these days. I hope you all worked out your issues
thanks for the plugin Dave, for anyone that might have making this work, the key is to installing the template page redirect pho file is to put it in the folder of you actual theme rather than your /theme root.
For example if you are using a theme named spacemonkey, you should probably put your theme in a folder like /wordpress/wp-content/themes/spacemonkey.2.2/spacemonkey
where all the other .php files are.
Hopefully this will same someone a few minutes of their time.
Fair point Mike. I’ve updated the main post.
this is thank you..
Thanks so much!!
Hi there – thanks so much for such an elegant solution!!
one question – if i have adsense on my pages (i do), will this get me in trouble with them? adsense requires a certain amount of text on my pages as per their terms of service, and if it isn’t there it can get you knocked off their program.
i know this works for humans, but will a bot ‘read’ the page as empty, besides a URL?
i guess i could write any old rubbish after the url (?), but i thought i’d check with the geniuses here
thanks you very much..