1

We have a site using WPML and the category archives like /categoryname/page/2 weren't working in the secondary language. I added /category/ to the permalink and now the pagination works, but I need help getting the paginated archive links to 301 redirect.

  1. I set up manual redirects for the main category archives using the Redirection plugin:
    • Ex: /categoryname/ redirects to: /category/categoryname/
  2. I need help with redirecting the paginated pages in the category archive.
    • Ex: http://example.com/categoryname/page/1 redirects to http://example.com/category/categoryname/page/1
  3. Single posts haven't been redirected because they work fine with /category/ in the permalink, and I'd love to keep it as-is if possible.
0

Add the following to your .htaccess, in between the <IfModule mod_rewrite.c>:

RewriteCond %{HTTP_HOST} !^(.*)/page/$
RewriteRule ^(.*)$ /category/$1/? [R=301,L]

Your default .htaccess created from WordPress should now look like the following:

# 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]
# Custom RewriteRule
RewriteCond %{HTTP_HOST} !^(.*)/page/$
RewriteRule ^(.*)$ /category/$1/? [R=301,L]
</IfModule>
# END WordPress
  • Thanks Ethan for answering! Unfortunately, it didn't work for me. The redirect doesn't happen. – Rebecca M Sep 7 '16 at 7:39
  • @RebeccaM Updated answer through the .htaccess route. Let me know if that works. – Ethan Jinks O'Sullivan Sep 13 '16 at 2:55

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.