Im trying to create a 301 redirect for all pages but one directory to a new site, but Im having trouble setting it up.
This is basically what I need:
http://www.example.com/store => no redirects, users remain on http://www.example.com/store
http://www.example.com/* => all other pages go to this url http://www.newdomain.com/
AKA
http://www.example.com/apple => http://www.newdomain.com/
http://www.example.com/pie => http://www.newdomain.com/
http://www.example.com/foo/bar => http://www.newdomain.com/
I tried this method:
RewriteEngine on
RewriteCond %{REQUEST_URI}!^/store/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
But when I go to http://www.example.com/store it takes me to http://www.newdomain.com/store
Basically I need the directory /store to remain on the old domain. Can anyone help? Not to experienced with .htaccess rules...
A 301 redirect is a permanent redirect from one URL to another. While they can redirect site page URLs, they can also redirect from one domain to another.
301 redirects should be used when a page is no longer relevant, useful or has been removed. They are also really valuable for site rebuilds, where URLs are tidied up into the newer, cleaner pages. It is very important to redirect any old URLs that won't be staying the same on a rebuild of your website.
The reasons for 301 redirect not working are much more well-defined among WordPress sites. One of the main causes is because you have added the rewrite rules on both the cPanel “Redirects” tool and from your WordPress plugin.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/store
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With