Welcome to WebmasterWorld Guest from 220.127.116.11
Here is the twist to my situation.
I am moving an entire site from www.myoldsite.com to www.mynewsite.com. The site has about 180 individual html pages.
ALSO changed - my high ranking page at: www.myoldsite.com/welcome.html will now be the index page at www.mynewsite.com. All other site structure remains the same.
I found this post that suggested:
RewriteRule (.*) http://www.newdomain.tld/$1 [R=301,QSA,L]
This will redirect all to the equivalent on the new domain, providing you keep the same directory structure.
The R=301 flag will ensure that the moved permanently header is returned to the caller, and the QSA (Query String Append) flag will rewrite your URI and append the original QUERY_STRING once rewritten.
Does this mean when someone clicks or requests www.myoldsite.com/page12.html they are taken to www.mynewsite.com/page12.html?
If that is the case, how do I get those requests made for www.myoldsite.com/welcome.html to go to www.mynewsite.com/index.html instead of www.mynewsite.com/welcome.html that will 404 since it won't exist?
Can I solve this in my redirect command in the olddomain .httacces or will this require another additional 301 located in the httaccess of the NEWdomain?
alternate example using mod_alias:
if I use both lines in the httaccess of the old site:
RedirectPermanent /welcome.html http://www.mynewsite.com/index.html
RedirectPermanent / http://www.mynewsite.com/
Will this do what i need, or will it just dump all page requests, including "welcome.html" to the index?
newbee and confused! THANKS
[edited by: jdMorgan at 3:03 am (utc) on Oct. 25, 2003]
[edit reason] De-linked [/edit]
Welcome to WebmasterWorld [webmasterworld.com]!
Your second code sample using RedirectPermanent will do exactly what you want.
The mod_rewrite code sample you show will redirect all pages to their equivalents on the new domain as shown. You can omit the [QSA] unless you want to add *more* parameters to the query string.
Using the mod_rewrite method, you need to use two directives, just like you use two directives for RedirectPermanent. First, take care of the exception (welcome page), and then redirect the rest to their equivalent pages in the new domain.
Either method will work for your needs. Have a look at mod_alias and mod_rewrite in the Apache modules documentation [httpd.apache.org].
One note: Unless you have a definite reason not to do it, I'd strongly recommend dumping "index.html" and just redirecting "welcome" to http://mynewdomain.com/
Let the server map "/" to index.html. This makes it much easier to change to .php or .shtml pages (just for examples) in the future, because none of your incoming links will have to change. Also, note that most popular site URLs do not have /index.html on the end. See Apache mod_dir for more info on defining the default index page name.