1

I have a domain that contains a shop installed in the root and WordPress in a subfolder called /web/

/public_html/ # shop
            /web/ # wordpress

I am in the process of moving the shop to a new domain. WordPress is remaining put.

I wish to 301 redirect all shop pages but exclude WordPress requests. This part works.

# Redirect shop to new domain
RewriteEngine on
RewriteCond %{REQUEST_URI} !^web($|/)$ 
RewriteRule (.*) http://www.new-domain.co.uk/$1 [R=301,L]

The following similar threads lead me to the above solution.

What I want to do now is make it so that visitors coming in to the old domain are simply redirected to /web/. I've tried adding:

RewriteCond %{REQUEST_URI} !^/index\.php$

but this is not working to exclude the root index file.

I think I need another RewriteRule in there somewhere.

Community
  • 1
  • 1
Gavin
  • 23
  • 1
  • 8
  • Replaced the !^/index\.php$ with RewriteCond %{REQUEST_URI} !^/$ to stop the index redirecting – Gavin Jan 16 '17 at 11:23

1 Answers1

0

After more trial and error I have come to the following result that is working for me.

# Redirect shop to new domain
RewriteEngine on
RewriteCond %{REQUEST_URI} !^web($|/)$ 
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) http://www.new-domain.co.uk/$1 [R=301,L]

# Redirect root to /web/
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://www.current-domain.co.uk/web/$1 [R=301,L]

I edited the first RewriteRule and excluded the root "/"

I then created a second RewriteRule moving only the root to "/web/"

Gavin
  • 23
  • 1
  • 8