1

How can I redirect all posts permalinks from .html to / in WordPress?

To be more clear, for example, a post URL like this:

http://example.com/%category%/%postname%.html

To be redirected to:

http://example.com/news/%postname%/.html

It's simple to redirect them one by one, but I need a rule to redirect all posts. My current .htaccess setup is:

# 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
1
  • Has this question been resolved? Commented Oct 13, 2016 at 14:00

1 Answer 1

0

Add this to your .htaccess below the # END WordPress line:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST}
RewriteRule ^(.*)/(.*).html$ news/$2/.html [L,R=301]
</IfModule>

This will redirect domains such as:

http://example.com/category/post-name.html

To the following:

http://example.com/news/post-name/.html
6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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