Apache specific path 301 redirects next to TLD redirect

Viewed 89

I am moving a blog hosted on an Apache server to a new domain.

The permalinks are kept the same for the blog posts but there are a few pages where the url slug will change on the new domain.

My question is if the following is possible and how I would do that with rewrite rules.

  1. The URL slugs/permalinks of the blog posts and most of the pages on the old domain will stay the same on the new domain. So I imagine that I could add a redirect rule that redirects from https://huiskopenomteverhuren.nl/ to https://vastgoedmentor.com as it will find the same /slug on the new domain

  2. Some pages of the old website have moved to new permalink. So I need additional rules to redirect for example https://huiskopenomteverhuren.nl/kennisbank/ to https://vastgoedmentor.com/resources and do this for a few other pages as well.

1 Answers

Could you please try following, written as per your shown samples. Please make sure you clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)huiskopenomteverhuren\.nl [NC]
RewriteRule ^ https://vastgoedmentor.com%{REQUEST_URI} [R=301,NE,L]

RewriteCond %{HTTP_HOST} vastgoedmentor\.com [NC]
RewriteCond %{REQUEST_URI} ^/kennisbank/?$ [NC]
RewriteRule ^ resources [L]
Related