We have been trying to create a dynamic redirect for the BuddyPress message Compose page using .htaccess rules. I would like for the Compose area to be inaccessible, but when someone clicks the "Private Message" button on someone’s profile, they can still get to the page and send a message to the user.
I found this post, but I can’t get my redirect to work – htaccess redirect exact match, exclude all query strings
The Compose area redirects to the home page fine, but when a query string is added during an attempt to message the user, we are redirected to the home page, but the query string remains in the URL.
Here is what I am using:
RewriteEngine On
RewriteBase /
RewriteRule ^members/([w-]+)/messages/compose/?$ / [L,R=302]
Any help on this would be appreciated.
Thank you.
2
Answers
This worked for me. Thanks everyone for your suggestions.
This should work for you. Remember to place the code at the top of your htaccess or before other directives .