0

Moving a lot of articles from the old site to Wordpress, the old site url is: www.domain.com/6272/post-title

where the new Wordpress :

www.domain.com/post-title

I checked the add_rewrite_rule and add_permastruct but I could not figure it how!

Thanks,

Marvix
  • 179
  • 3
  • 16
  • Possible duplicate of [How to remove Post ID from posts and then redirect to new URL?](https://stackoverflow.com/questions/11317163/how-to-remove-post-id-from-posts-and-then-redirect-to-new-url) – cabrerahector Sep 27 '18 at 20:44
  • I think you are look for a redirect method with wildcard check [this](https://stackoverflow.com/questions/6877486/how-can-i-use-htaccess-to-redirect-paths-with-a-wildcard-character) out. You should work on the old site site to tackle the problem instead of on the new site. – Qiao Li Sep 28 '18 at 12:56

3 Answers3

0

if source and destination are both wordpress:

you must edit with norepad++ the sql export, that come from phomyadmin, and replace the old paths with new.

If the site is small you can use the plugin Duplicator, or other plugins that are asking to set the new url.

If the source site it is not wp you must write a plugin or search to see what exist for the techonoly of your sourse.

  • The old site was built with Yii2. Moreover; Google bots will not find the old site url, and will return 404, which is bad, I must have multiple structures. The most first time the site was made with Drupal 6, then migrated to custom-made Yii2, and now Wordpress. The Drupal urls : www.site.com/node/73731 The Yii2 urls: www.site.com/article/32222 WIth Yii2 was easy to create whatever url structure, but am a bit confused with Wordpress now. The site has over 300K articles. The idea is to get the requested url and take requested ID, and rewrite to the new url. Thanks, – Marvix Sep 27 '18 at 19:45
  • when I was working to a big German company in Greece, I had the problem to migrate the old Accounting system to SAP, I did it with Pro*C. I think you need a custom php program to export the articles from DB, manipulate as you need and import to wordpress db. – Elias Katsaniotis Sep 28 '18 at 04:01
0

I'm not sure if your server is running apache or nginx, but making 301 redirects sounds like what you need.

For apache, this will go in an .htaccess file in the root of your website

Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html

Redirect 301 /6272/post-title /post-title

Read more here: https://css-tricks.com/snippets/htaccess/301-redirects/


For nginx, this will go in the sites config file in /etc/nginx/sites-available/yoursite.conf

server {

  listen 80
  listen 443;

  server_name www.domain.com;

  location /6272/post-title {
    return 301 www.domain.com/post-title;
  }

}

Read more here: https://www.digitalocean.com/community/questions/setting-up-a-301-redirect-with-nginx-for-my-ghost-blog

Tanner Eustice
  • 164
  • 1
  • 9
  • That would the aoultion if the post of is the same in the and the new site, but they are different. The old site url I kept in the postmeta table in the DB, so I will a function to get the post of from the requested url and then search in the postmeta, then forward the page to the new one. – Marvix Sep 28 '18 at 06:18
  • One more thing, am talking about site with over 300K post. Please read below m6 comment. – Marvix Sep 28 '18 at 06:20
0

What I was searching for a way to get the old post ID and search the post meta for it if found then redirect to the post with 301.

Posting the code for reference & enhancement here:

`https://pastebin.com/ncjEWQsc`

I hope someone can review it.

Marvix
  • 179
  • 3
  • 16