Ready to get started?Download WordPress


How to redirect all posts but not pages (1 post)

  1. TJ Kelly
    Posted 1 year ago #

    I want to move my posts under a /blog directory. I have a few hundred posts, so I want to move them en masse using regex (rather than one by one). However, I don't want my page URLs to change.

    domain.com/post-name/ => domain.com/blog/post-name/
    domain.com/another-post/ => domain.com/blog/another-post/
    domain.com/page-name/ => stays the same

    I've tried things like this in my htaccess, but it didn't work...

    RewriteCond %{REQUEST_URI} !^\/(about|contact)\/
    RewriteRule ^$ /blog/$1/

    ...also tried...

    RewriteCond %{REQUEST_URI} !^\/about\/
    RewriteCond %{REQUEST_URI} !^\/contact\/
    RewriteRule ^$ /blog/$1/

    Would love to figure out an .htaccess or Redirection fix for this!


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.