.htaccess redirect help

need to code the following…




ive tried numerous redirects but haven’t found one that works

Do you mean users will visit
but be redirected to

No, I need users directed to the new slug:


Be warned that using permalinks of that format (with no post ID or date fragment) can have severe negative impacts on your blog’s performance, especially if you have many posts. See http://ottopress.com/2010/category-in-permalinks-considered-harmful/ for details.

I’ve used this format and its been just fine. Many others do the same.

Sadly I still do not have an answer to my original question.

You need to do this:

Redirect 301 /example.com/long-post/long-listing/post /example.com/to-short-post

so in your case add this to your .htaccess file

Redirect 301 example.com/post/123456789/sample-post-here example.com/sample-post-here

Notice the space between the two paths.

That would work for one URL but I have hundreds

the numeric values and sample-post are always different

ah. then you need some regular expressions included in there. That’s more complex but if you post 4 - 5 sample URLS i might be able to help you out. What type of site is this? (wordpress? joomla? drupal? phpbb? – your own?)…


The numbers are always different as is the end part of the slug

This is a wordpress site

Basically I want the old posts to transfer to the new format

The numerical and post part of the slug removed

The WordPress part is significant but in this case it doesn’t matter much. Did you get this resolved?

You have two options if you’re still looking for an answer. Install the plugin Redirection, and use the regex/regular expression option to describe your urls and explain what you want to do and the plugin will do it. The other more complex but “better” way of doing it is to edit your .htaccess to add your regex rules.

Regex is complicated but it allows you to target a lot of urls at once by making pattern-matching searches instead of specific urls. This could be a great starting point for you as they describe some of what I’m talking about towards the middle-bottom of the article. - http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html – And usually people hate this next link because it makes you think and you actually learn… but its one of the best regex resources out there - http://www.regular-expressions.info/

good luck.