Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Slug Rewrite
- */
- add_action( 'template_redirect', 'mh_slug_rewrite' );
- function mh_slug_rewrite() {
- // http://website.com/?slug=product_info.php&products_id=32 to http://website.com/products/32
- if ( strpos( $_SERVER['REQUEST_URI'], '?slug=product_info.php&products_id=' ) ) {
- wp_redirect( str_replace( '?slug=product_info.php&products_id=' , '/products' , $_SERVER['REQUEST_URI'] ) );
- exit();
- }
- // http://website.com/?slug=register.php to http://website.com/register
- if ( strpos( $_SERVER['REQUEST_URI'], '?slug=register.php' ) ) {
- wp_redirect( str_replace( '?slug=register.php' , '/register' , $_SERVER['REQUEST_URI'] ) );
- exit();
- }
- // http://website.com/?slug=index.php&cPath=1 to http://website.com/category/1
- if ( strpos( $_SERVER['REQUEST_URI'], 'http://website.com/category/1' ) ) {
- wp_redirect( str_replace( 'http://website.com/category/1' , '/register' , $_SERVER['REQUEST_URI'] ) );
- exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement