How can I redirect all posts to a corresponding product page?

7 Zulu

Newbie
Joined
Jan 14, 2011
Messages
26
Reaction score
6
Hi friends :)

I want to try something a little over my head.

I have a test site in wordpress, and I want to redirect every post to a product page, and it simply involves substitution, so I am thinking a wordpress plugin using regex?

It would be very simple, for example, if my permalink contains:

rubber-ducky

I would like to change the url that I am linking to within my own site to:

shop.php?k=rubber-ducky

Is there a plugin for this?

And yes, I know this is not a good way to make a website, this is just experimental :D
 
Possible PHP solution:

PHP:
<?php 
if ($_SERVER['REQUEST_URI']=='rubber-ducky' ) {
header( 'Location: shop.php?k=rubber-ducky' ) ;
} elseif ($_SERVER['REQUEST_URI']=='some-other-keyword' ) {
header( 'Location: shop.php?k=some-other-keyword' ) ;
} elseif ($_SERVER['REQUEST_URI']=='yet-another-keyword' ) {
header( 'Location: shop.php?k=yet-another-keyword' ) ;
} 
?>

Place it before all html in the header section of Wordpress editor.

Not sure if this works because I'm tired but you may as well test it and see.
 
Last edited:
Very Nice! Has anyone tested this to see if it works?^^^^
 
Back
Top