Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can i redirect all posts permalinks from .html to / ,in Wordpress ? now all my posts url are ending in / ,but before it was with .html

to be more clear ,for example a post url like this http://sitename.com/%category%/%postname%.html to be redirected to http://sitename.com/%year%/%monthnum%/%postname%/ . It's simple to redirect them one by one,but i need a rule to redirect all posts .

my curent .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

======

Thank you

share|improve this question

2 Answers 2

it's curious that redirect_canonical doesn't work in this case, but this will redirect everything with .html via .htaccess:

RewriteRule (.+)\.html?$ http://example.com/$1/ [R=301,L]

but keep in mind this will redirect everything with .html, you may need to explicitly exclude things.

share|improve this answer
    
works like a charm , thanks very much Milo! –  rigo Sep 14 '11 at 15:24
    
you didn't check it as a valid answer ;) –  Olivier Pons Nov 23 '11 at 11:21

That's strange. I thought WordPress did that automatically. Here's the default one that WordPress generated for me:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Try that on for size. Note how this one includes <IfModule mod_rewrite.c> and </IfModule>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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