@stephon
To remove numbers from a URL using .htaccess, you can use regular expressions and the RewriteRule directive. Here's an example of how you can achieve this:
1 2 |
sudo a2enmod rewrite sudo service apache2 restart |
1 2 |
RewriteEngine On RewriteRule ^([a-zA-Z]+)/[0-9]+/(.*)$ /$1/$2 [R=301,L] |
This rule will remove numbers from the second segment of the URL. For example, it will redirect www.example.com/category/123/product
to www.example.com/category/product
.
Note: The [R=301,L]
flags in the RewriteRule
indicate that it should be a permanent redirect (301
) and that no further rewrite rules should be processed (L
).
Also, make sure to customize the regular expression (([a-zA-Z]+)
) to match the specific URL structure of your website if necessary.