admin管理员组

文章数量:1332377

I'm trying to write a redirect so that anyone who tries visiting "www.example.au" is directed to "www.example", but I'm not sure how to do that in my .htaccess file.

So far, I've tried:

RedirectMatch 301 ^.au /
RedirectMatch 301  /
RedirectMatch 301 ^.au /

But I'm not seeing any results. What's the proper way to setup this redirect?

I'm trying to write a redirect so that anyone who tries visiting "www.example.au" is directed to "www.example", but I'm not sure how to do that in my .htaccess file.

So far, I've tried:

RedirectMatch 301 ^.au /
RedirectMatch 301 https://www.example.au /
RedirectMatch 301 ^.au /

But I'm not seeing any results. What's the proper way to setup this redirect?

Share Improve this question asked Jul 6, 2020 at 13:42 James RandolphJames Randolph 1 2
  • Added an answer, and for reference note this isn't specifically a Wordpress question, even though it may be to do with a Wordpress site for you. You may find this quesiton gets closed or you get better results for non Wordpress questions on stack overflow or server fault – mozboz Commented Jul 6, 2020 at 14:09
  • What you describe is not a "subdomain" redirect; it's an entirely different domain. – MrWhite Commented Jul 6, 2020 at 15:07
Add a comment  | 

1 Answer 1

Reset to default 1

Found answer here, first result by searching redirect to different domain apache htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^example.au$ [OR]
  RewriteCond %{HTTP_HOST} ^www.example.au$
  RewriteRule (.*)$ http://www.example/$1 [R=301,L]
</IfModule>

It doesn't matter if just your TLD is different the same format will work

本文标签: htaccessHow do I write a subdomain redirect