Suppose I have urls like these:


I would like to only keep the id part:


The id always has 13 digits.

This is what I tried but it's not working.

RewriteRule ^(id-[0-9]{13}) $1 [L]

Can someone please help me out? Thanks.

  • What exactly is "not working"? – Michael Hampton Aug 5 at 21:20
  • Where is your .htaccess file? Ordinarily, when you "remove" part of a URL you need to trigger an external "redirect", yet you appear to be rewriting the URL instead? Is that intentional? Presumably, you have other directives - please include the entire contents of your .htaccess file - conflicts with existing directives is a common problem. – MrWhite Aug 5 at 23:42
  • The caret causes it to only match id- at the start of a path. If you're looking for /toys/id- then the id- is not at the start of the path so it won't match. – tetech Aug 6 at 0:02
  • @tetech That depends on where the .htaccess file is located - which hasn't been stated. – MrWhite Aug 6 at 0:18
  • @MrWhite Agreed. – tetech Aug 6 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.