I have made a change to my site so that it is no longer in a subdirectory of my root domain. (it is now in the root of the domain).
I have made the move successfully but I would like to put a 301 redirect into my htaccess so that people visiting the old links make it to the new site.
So basically, I am looking for something that would say if any one goes to www.mysite.com/olddirectory/wildcard_here they would be redirected to www.mysite.com/wildcard_here .
On another site, I was doing something similar but in the other direction. I had moved a site into a directory from the root, so I had
RewriteEngine on
RewriteCond $1 !^newdirectory
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
Is there any way to do what I am trying to do? It is important that if some one goes to a directory that is not “olddirectory”, they should not be redirected.
You were correct in your assumption that I did not try your suggestion. At the time, I did not have access to my ftp, so I could not try it. I did however read the link you provided, I was just confused as there was no wildcard apparent in the redirect, so I did not expect it to work.
I have now tested it and it is working perfectly! Thank you for your help!
If you’re still confused, PLEASE ask questions as it’s important to me that you know WHY things work (so you can help others learn when you get the chance).
Did you try it? Okay, obviously not! From that response, I’m sure you didn’t even go look at the Apache.org page! Oh, well, when you do, you’ll learn that mod_alias will work on that directory as specified (removing it from the URLs with a permanent redirection).