0

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.

Hobo
  • 7,536
  • 5
  • 40
  • 50
mhp
  • 11
  • 1

1 Answers1

0

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]
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121