I have a Drupal 5.x based travel review site which I'm moving over to Wordpress 3.x (same domain name).

The Drupal site is structured like this:

  • www.example.com/travel-guides (these are top-level pages) - these are only a handful.
  • www.example.com/<filename>.html (filename is the name of a place / attraction etc). - makes up for bulk of the content in the site.

In WordPress the setup is fairly straightforward. All content follows a simple permalink:


How do I set a rule in .htaccess to bulk redirect all the pages? There are over 600 pages and I don't want to manually set redirect rules for all of them.


Above the WordPress rewrite rules add:

RedirectMatch permanent ^/([^/]+)\.html$ /$1

That will catch example.com/foo.html but not example.com/travel-guides/foo.html. To catch all URLs ending with .html remove the first ^ from the pattern.

To redirect all URLs ending with .html except those in travel-guides you need mod_rewrite:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/travel-guides/
RewriteRule ([^/]+)\.html$  /$1 [L,R=301]
  • Thanks toscho. Will implement that. But how do I set redirects for URLs within a folder but not example.com/travel-guides/foo.html. I'm not too familiar with coding but usually follow DIY guides. So this would be a 301 redirect right? – user10718 Oct 20 '12 at 10:01
  • @user10718 See my update. Both rules send a 301. – fuxia Oct 20 '12 at 10:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.