0

I have thousands of URLs that look like this:

http://www.domain.com/here-is-a-product-ab00007a1.html

The number at the end of the URL (before the .html) is the SKU. The site has recently been relaunched and these numbers no longer exist in the URLs.

I would like to redirect all URLs like this to their new version which does not include the SKU, example:

http://www.domain.com/here-is-a-product.html

Any help would be greatly appreciated! Thank you.

===== EDIT =====

The actual sku format is like so:

aa00000a00

There are always 2 letters, followed by 5 numbers, followed by 1 letter, followed by 2 numbers.

The sku is always 10 characters long.

3
  • So is there any difference between the SKU and the last word in a product? Like are SKU's always end in a number? Commented Aug 14, 2012 at 0:45
  • Yeah, the sku is always the same format. Starts with two letters, has a series of numbers, then has a letter and a number at the end. Commented Aug 14, 2012 at 0:53
  • FYI, the original example of the sku was not precise, so I edited the question. Please see the EDIT. Commented Aug 14, 2012 at 0:56

1 Answer 1

1

Try putting this in the htaccess file in your document root:

RewriteEngine On
RewriteRule ^(.*)-[a-z]{2}[0-9]{5}[a-z][0-9]{2}\.html$ /$1.html [L,NC]

You can also put that in your vhost/server config if you'd rather do that, just remove the leading slash from the rule's target so that it's simply: $1.html

Sign up to request clarification or add additional context in comments.

1 Comment

Worked perfectly! I had to add a R=301 for it to resolve, but otherwise it's perfect!! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.