0

I am using apache2 + tomcat on ubuntu 10.4. I am running on tomcat server that has webapps listening on 8080

trying to redirect domain.com/category/post-name.html to new url >

domain.com/newcategory/blogs/category/post-name

what is the best possible way to achive this?

so far I have...

RewriteCond %{REQUEST_URI} ^/[a-zA-z0-9]+/[a-zA-z0-9]+/(.*)?\.html$
RewriteRule ^/[a-zA-z0-9]+/[a-zA-z0-9]+/(.*)?\.html$ http://www.domain.com/newcategory/blogs/$1 [R=301,NC,L]
bay
  • 35
  • 3
  • [How to hide the .html extension with Apache mod_rewrite](http://stackoverflow.com/questions/1992183/how-to-hide-the-html-extension-with-apache-mod-rewrite), [How to remove file extension from website address?](http://stackoverflow.com/questions/6534904/how-to-remove-file-extension-from-website-address-sample-photos-attached), [remove .php extension with .htaccess](http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess), and dozens more. – ЯegDwight Oct 01 '12 at 10:18
  • well, thank you for the links. I have checked them out. However, I am not only trying to get rid of just the ".html" part - I need to properly redirect over 20,000 posts the url redirect above seems as it would do the trick, but it doesnt work. So, I am trying to figure out if I am missing something. – bay Oct 01 '12 at 10:32

1 Answers1

0

It looks like the post-name carries over to the redirected URL, and so does the category, but the newcategory/blogs part would have to be hardcoded because there's nothing to pull that from the old URL:

RewriteCond %{REQUEST_URI} !^/newcategory/blogs
RewriteRule ^/?([^/]+)/([^/]+)\.html$ http://www.domain.com/newcategory/blogs/$1/$2 [L,R=301]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220