I have a WordPress site and a custom site and send a user from the WordPress site to the custom site when they navigate to a specific URL. Let’s say the main WP site is located at www.example.com. If someone goes to http://example.com/p/M12345, we want to send it to https://my.example.com/myexample/members/login.html?login=M12345. I thought the best way to do this would be to use mod_rewrite in the .htaccess file
I tried setting this up the main .htaccess file, but nothing seemed to work. The WP site at www.example.com uses a redirect plugin which normally takes care of this, but last week it messed up our entire site, so I am reluctant to continue using it. I would like to use the .htaccess file since this feels like the correct way to do it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(\/p\/)([mM]\d{5})$ https://my.example.com/myexample/members/login.html?login=$2 [R=301,L]
</IfModule>
A few things we have tried:
adding flags such as [NC,R=301,L], [L,QSA] and others
changed RewriteRule to Redirect 301 and removed the flags
added RewriteCond ^(/p/)$ thinking this would only occur on the example.com/p/ pages
What is the correct way to get this working?