Title: Slug redirection
Last modified: September 3, 2024

---

# Slug redirection

 *  Resolved [Alexandros](https://wordpress.org/support/users/alprio/)
 * (@alprio)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/slug-redirection/)
 * Hello, 
   How can I disable the slug redirection ?For example,on products I removed
   the /procuct from url , but if someone visits [http://www.example.com/product/cat/post](http://www.example.com/product/cat/post)
   it redirect them to [http://www.example.com/cat/post](http://www.example.com/cat/post)
   I want if someone visits [http://www.example.com/product/cat/post](http://www.example.com/product/cat/post)
   to get 404.because index now , send both urls for indexing.
 * is it possible ?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/slug-redirection/#post-17991608)
 * Hi [@alprio](https://wordpress.org/support/users/alprio/),
 * Unfortunately, there is no out-of-box solution available. A few years ago I prepared
   a custom snippet that should do exactly what you are trying to do. Here is the
   code:
 *     ```wp-block-code
       function pm_force_404_on_native_permalinks() {	global $wp_query, $pm_query, $permalink_manager_uris;	// 1. Get the queried object	$object = get_queried_object();	// 2. Use it only if no custom permalink is detected	if ( ! empty( $pm_query['id'] ) ) {		return;	}	// 3. Check if the custom permalink exists for requested item	if ( ! empty( $object->post_type ) ) {		$has_custom_uri = $permalink_manager_uris[ $object->ID ];	}	// 4. Force "404" error page	if ( ! empty( $has_custom_uri ) ) {		$wp_query->query = $wp_query->queried_object = $wp_query->queried_object_id = null;		$wp_query->set_404();		status_header( 404 );		nocache_headers();		$pm_query = '';		// Disable canonical redirect		remove_action( 'template_redirect', 'wp_old_slug_redirect' );		remove_action( 'template_redirect', 'redirect_canonical' );	}}add_action( 'wp', 'pm_force_404_on_native_permalinks', 5 );
       ```
   
 *  Thread Starter [Alexandros](https://wordpress.org/support/users/alprio/)
 * (@alprio)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/slug-redirection/#post-17991700)
 * Hello again ,
 * Thank you for the snippet.
   I did some tests and it seems that is working correctly
   for products.is it possible to expand this snippet for /product-category/ slug
   too ?
 *  Plugin Author [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * (@mbis)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/slug-redirection/#post-17991709)
 * Hi [@alprio](https://wordpress.org/support/users/alprio/),
 * Yes, as this requires Pro version to work, please send the support request with
   your license key here:
   [https://permalinkmanager.pro/contact/](https://permalinkmanager.pro/contact/)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Slug redirection’ is closed to new replies.

 * ![](https://ps.w.org/permalink-manager/assets/icon.svg?rev=2625166)
 * [Permalink Manager Lite](https://wordpress.org/plugins/permalink-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/permalink-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/permalink-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/permalink-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/permalink-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/permalink-manager/reviews/)

## Tags

 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * 3 replies
 * 2 participants
 * Last reply from: [Maciej Bis](https://wordpress.org/support/users/mbis/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/slug-redirection/#post-17991709)
 * Status: resolved