Regex help for addon domain

47 views Asked by At

we recently moved to an addon domain. I'm having problems with the redirect. I need to redirect for the following situations:

  1. mydomain.com/mysubfolder/ to mysubfolder.com
  2. mydomain.com/mysubfolder/wp-login.php? to mysubfolder.com/wp-login.php?
  3. mydomain.com/mysubfolder/page/ to mysubfolder.com/page/ [there are many pages]

This is my current regex:

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/wp-login.php
RewriteRule ^/mysubfolder/(.*)$ http://www.mysubfolder.com/$1 [L,R=301]

It takes care of points 1 and 2. But I can't figure how to take care of point 3.

Thanks in advance.

1

There are 1 answers

0
Lorenz Meyer On

Your regex redirects all pages except wp-login.php. It also does not account for the URL without the trailing slash. I added the ? to correct this.

RewriteEngine on
RewritRule ^/mysubfolder/?(.*)$ http://www.mysubfolder.com/$1 [L,R=301]