Advertisement
jan_dembowski

mh-slug-rewrite.php

Feb 15th, 2012
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Slug Rewrite
  4. */
  5.  
  6. add_action( 'template_redirect', 'mh_slug_rewrite' );
  7. function mh_slug_rewrite() {
  8.  
  9. // http://website.com/?slug=product_info.php&products_id=32 to http://website.com/products/32
  10.    if ( strpos( $_SERVER['REQUEST_URI'], '?slug=product_info.php&products_id=' ) ) {
  11.       wp_redirect( str_replace( '?slug=product_info.php&products_id=' , '/products' , $_SERVER['REQUEST_URI'] ) );
  12.       exit();
  13.    }
  14.  
  15. // http://website.com/?slug=register.php to http://website.com/register
  16.    if ( strpos( $_SERVER['REQUEST_URI'], '?slug=register.php' ) ) {
  17.       wp_redirect( str_replace( '?slug=register.php' , '/register' , $_SERVER['REQUEST_URI'] ) );
  18.       exit();
  19.    }
  20.  
  21. // http://website.com/?slug=index.php&cPath=1 to http://website.com/category/1
  22.    if ( strpos( $_SERVER['REQUEST_URI'], 'http://website.com/category/1' ) ) {
  23.       wp_redirect( str_replace( 'http://website.com/category/1' , '/register' , $_SERVER['REQUEST_URI'] ) );
  24.       exit();
  25.    }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement