I want to redirect my subdomain registration page to my domain registration page in .htaccess for wordpress multisite. I am using the below code but it does not work.
//301 Redirect Entire Directory
RedirectMatch 301 http://sub.domain.com/register/(.*) http://domain.com/register//$1
What do I miss?
You cannot use mod_alias(redirectmatch)
in that way. You have to use mod_rewrite
if you want to match based on the hostname.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$
RewriteRule ^register/(.*)$ http://domain.com/register/$1 [R=301,L]
If the .htaccess is in the root of sub.domain.com then you can just do this but using the absolute path.
RedirectMatch 301 ^/register/(.*)$ http://domain.com/register/$1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.