Redirect Subdomain to Main Domain

[ad_1]

Hey,

Can’t get the bottom of the correct .htaccess rule to achieve the following:

[server.example.com]) \- the WordPress install
[example.com]) \- the React frontend

I want all requests to [server.example.com]) to redirect to [example.com]) except:

[server.example.com/wp-admin])

[server.example.com/wp-content])

*and some others, but i can add these into the rule later.*

I have tried the following rule (and many others) but can’t get the correct redirect. This rule allows access to /wp-admin and successfully redirects [server.example.com]) to [example.com]) but will not redirect [server.example.com/anything\_else]) to [example.com])

<IfModule mod\_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST\_URI} !\^/(wp-content|wp-admin|wp-login.php)($|/) \[NC\]

RewriteRule \^ [https://example.com]{REQUEST\_URI} \[R=301,L\]

</IfModule>

Any advice appreciated!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer