Friday , December 20 2024

301 redirect with numbers removed from URL

I have a case – for all product URLs, I need to remove numbers and dashes with a 301 redirect, for example: remove 1234- from /category/1234-product/.

Instead of 1234- there can be any numbers.

But at the same time, I don’t need to change the URL /0192-test/ in the root of the site. Here is a .htaccess mask rule that solves this problem:

RedirectMatch 301 ^/category/([0-9]+)-(.*)/$ /category/$2/

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

How to find changed files in console

Relevant for Linux, macOS. This article lists commands that help you find files that have …

Leave a Reply

Your email address will not be published. Required fields are marked *