Wordpress Redirect All Posts

Nolshestoy

Newbie
Joined
Mar 26, 2013
Messages
42
Reaction score
1
Hello,

does someone maybe know how it's possible to redirect all posts to a certain URL? I mean, I have the php code ready, but I don't really know where to add that. What page is required to make that work for every post? Or is there a plugin for this?

Help would be appreciated!
 
Paste it in Single.php to redirect all posts. Header.php for the whole site or just redirect the whole domain from your control panel.

Code:
<meta http-equiv="refresh" content="0;url=[I]http://domain.com[/I]" />
 
dont know of such a plugin but i have previously used one where you can redirect each page or post to another url. but you can only do this one by one.
 
In your wordpress theme,
under wp-content/themes/your_theme directory,
you can either edit the header.php directly or
you go to your wordpress admin, Appearance | Editor and add the redirect code in the header.php

Hth
 
That doesn't work unfortunately. I actually get every page of Wordpress redirected, except the post page. I also have a loop of different URL's to which every post should be redirected.
 
If it would be that easy, I wouldn't write a thread. As I said, I tried everything and nothing works, also I have a loop of different URL's to which every post shall be randomly redirected. These plugins are only for one URL and too complicated if you have to set every post individually up.
 
Last edited:
I already edited the header.php and as I already mentioned it redirects every page except the post page.
 
That doesn't work unfortunately. I actually get every page of Wordpress redirected, except the post page. I also have a loop of different URL's to which every post should be redirected.
It's really hard to know what you're talking about when you've got several answers. Saying "THAT doesn't work" wont help us to understand your problem.
You use a catch plugin?

So sad to see the other responders telling you to get a plugin for such a simple thing. No wonder WP sites keeps getting hacked when everyone need a plugin to change the font color, re-size an image, change background or adding a signature at the bottom of the post.

EDIT
I already edited the header.php and as I already mentioned it redirects every page except the post page.
You have some mess-up theme that doesn't load the header?
Single.php's first line should be <?php get_header(); ?> in order to load header.php
 
Last edited:
What's hard here to understand? I simply want to redirect all the posts to several URL's which change randomly. Your idea doesn't work!
 
You have some mess-up theme that doesn't load the header?
Single.php's first line should be <?php get_header(); ?> in order to load header.php

I see now, your method works but it opens the page first, then redirects after 5 seconds or something.

Don't you have a better solution, where it redirects instantly?
 
so you don't need all the existing posts/pages right?
Add following codes to your header.php, at the very beginning of <head>;
Code:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: target"); 
exit(); 
?>


Remember to replace target with your own link.
 
Last edited:
I see now, your method works but it opens the page first, then redirects after 5 seconds or something.

Don't you have a better solution, where it redirects instantly?

I suppose you are using html refresh if it's 5 seconds.

Just change the time to 0

Code:
<meta http-equiv="refresh" content="0; url=http://example.com/" />
 
Depends what you are trying to do, you have not really given enough information here.

Here's your options, and me guessing at your situation.

A. Do a 301 redirect (You can do this from your registrar, or an .htaccess file, this is the simplest way to 301 the entire domain to a new location.)

B. If your on a subdomain, or moved the old blog to a new directory, you can run an sql query via phpmyadmin. You want to run a search and replace on the wp_posts table. I'll assume you've already ported/moved your site to the new location - So run a search and replace query on wp_posts/wp_posts meta and replace olddomain with newdomain. This will leave the old site intact, but all the links will lead to the new location.
 
Back
Top