Support » Fixing WordPress » Permalink: How to create custom blog post URL’s in new site

  • [ Moderator note: moved to Fixing WordPress. Please do not use Developing with WordPress for these topics. ]

    I am new to WordPress but hoping someone can help me with this problem:

    Old Site: Moving site (keeping same domain) from non-WP CMS to WP. On my old site’s blog I have about 20 posts that use URL’s such as:

    New WP Site: I want to start creating new blog posts with the following structure:

    I want the old blog posts to appear on my new site blog but I want to keep the old blog url’s and not change them. Is there a way to create custom blog post URL’s in WP for the old posts and still have the new posts moving forward use the new URL structure.

    FYI: I need to do this because I am moving from http: to https: at the same time and it is preferred by Google that you don’t change your URL structure at the same time you do the https migration.

    Any help is appreciated on this!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You can set up 301 redirects. This tells Google the post has been moved, and it redirects anyone to the post at the new url.

    Thanks for the reply! Google does not approve of doing 301 redirects at the same time you do a http to https migration which is why I need to keep the old blog post URL’s.

    A little background these blog posts make up 70% of my traffic which I don’t want to lose the organic traffic.

    Hmm, that is news to me about Google’s http to https method. I would look up any *official* webmaster guidelines they may have about this scenario. It doesn’t seem too uncommon to me, especially since Google is now recommending everyone use an SSL.

    And see if there’s anything that can help you in the Google console/webmaster tools.

    John Mueller of Google stated that you should not do 301 redirects during a http to https migration if you want to make sure thet all the URL’s are found quickly without any extended delay. As you may know he is the voice of Google these days after Cutt’s left.

    Which is why I was hoping there is a way to preserve the old URL’s when I move to WP.

    Moderator bcworkz


    You can construct relative rewrite rules in .htaccess that rewrite the old URLs to the new one. As long as the destination rewrite does not include protocol or domain elements, relative paths only, the rewrite remains internal. As far as the browser or Goggle bot is concerned, the original request succeeded with a 200 status.

    You will need as little as 2 conditions to match or as many as 20, one for each URL. Either way, this is manageable. If there were 200+ URLs, you would need to find some algorithm to define what to rewrite since writing individual conditions becomes untenable.

    After the HTTPS change has settled in, if you are correct about not combining with 301s, you still will want to eventually convert to 301 redirects some time in the future, or you will be stuck with the old structure for ever.


    Thanks for your reply! I am not skilled in htaccess coding, do you have an example or link to an example of a relative rewrite rule?

    And you are correct the plan is to let the HTTPS get established in Google’s eyes then move to step 2 and properly 301 redirect the old URL’s to the WP standard format.

    Moderator bcworkz


    I’m not good at .htaccess either 🙁

    Most of my efforts involve intentional 301 redirects. I attempted altering the default WP rewrite rule, which we all know works as expected with no 301.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_URI} ^/blog/old-path/page-slug/?$ [NC]
    RewriteRule . /index.php&p=1234 [L]

    While this appears to work as expected (assuming 1234 is the proper post ID for “page-slug”), it unfortunately still results in a 301 redirect being sent 🙁 I believe this redirect works internally without any 301, but WP altering the p=1234 into the current permastruct is what generates the 301.

    Curiously, if “blog”, “news”, “apparel”, etc. do not match any known WP query vars, you do not need any additional rewrite rules at all, WP will determine the proper post based on the slug alone and internally rewrite to the new permastruct. This still results in a 301 being sent though.

    Thus, if the HTTPS change needs to be separated from 301 changes, it appears the 301s need to be done first, followed by the change to HTTPS in the future. Obviously this is far from ideal since HTTPS resolves several security weaknesses.

    Thanks bcworkz for the info!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Permalink: How to create custom blog post URL’s in new site’ is closed to new replies.