I wonder if this would world:
RedirectMatch 301 /\d{4}/\d{2}/\d{2}/(.*) /$1
Thanks Ipstenu,
I tried but it doesn’t work.
I get the same error above,like: http://example.com/postname without the blog path.
is it possible it doesn’t exist a command that say “take the full path”????
Oh right, cause / starts at example.com … Hm.
How does this work?
RedirectMatch 301 /\d{4}/\d{2}/\d{2}/(.*) $1
I give you an real example:
I’ve this url
http://travellertribe.com/hamburg/2010/06/07/hafengeburtstag-hamburg/
when I put
RedirectMatch 301 /\d{4}/\d{2}/\d{2}/(.*) $1
and than change permalink on /%postname%/
if i go to
http://travellertribe.com/hamburg/2010/06/07/hafengeburtstag-hamburg/
I get
http://travellertribe.com/hafengeburtstag-hamburg/
as you can see I lost /hamburg/
No, I got that π I just am not in a place where I can play with .htaccess for that effect myself (work, today it’s all windows servers).
The problem is that the match ($1
) is automagically flipping back to the root URL (example.com) so you get example.com/replacement :/
Other than doing a ton of these:
RedirectMatch 301 /foobar/\d{4}/\d{2}/\d{2}/(.*) /foobar/$1
I can’t think of a quick fix.
Maybe this:
RedirectMatch 301 /(.*)/\d{4}/\d{2}/\d{2}/(.*) /$1/$2
But I don’t know if that would work. You may need to refine that first (.*)
and tell it to look for A word, and not ‘anything’
Before you put too much work into changing your permalinks to jujst postname, please read the following:
http://ottopress.com/2010/category-in-permalinks-considered-harmful/
Thanks Andrea for the intresting article,
but I’ve to change permalink in order to use a plugin too.
@ipstenu you rock!
I tryed your way and it works!!!!
thanks again, cheers from Italy
FWIW, Yoast’s article, linked at the top, has some pretty valid arguments why %postname%
should be fine for MOST people (who aren’t on bottom line hosting and use any caching tools). I always toss a ‘folder’ name in there, so I get domain.com/news/foo or domain.com/blog/foo, but really the point is this:
If you understand what you’re getting into with short permalinks, and know how to handle it, you’re fine. If you’ve got no idea what it all means, for god’s sack, don’t do it!
How about if I wanted to switch from domain.com/post/ to domain.com/category/post/? Recently did that and am attempting to repair my flood of 404’s. Tried permalink plugins to fix it but it seems I need to make an individual redirect for each 404 that comes in.
THAT I would not do (/category/post/).
If you do, however, you will need to redirect each post, because there’s no good way to detect the postname and parse for category.
Ok, switched back to /postname/ now… how to I redirect the /%category%/%postname%/ requests back to /%postname%/? to fix the future 404 errors i’ll get from submitting my previous sitemap to google webmaster tools. Or will those just go away? (since I haven’t backlinked any of the new structure to 3rd party sites)
For each category:
RedirectMatch 301 /categoryname/(.*) /$1