homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

permanent redirect dilemma

10+ Year Member

Msg#: 490 posted 2:36 am on Oct 25, 2003 (gmt 0)

I have been reading thru the many posts found by searching under "permanent redirect". Much makes sense even to this newbee, and can impliment the all moved or single page move.

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:

RewriteEngine on
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]



WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 490 posted 3:00 am on Oct 25, 2003 (gmt 0)


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.



10+ Year Member

Msg#: 490 posted 3:12 am on Oct 25, 2003 (gmt 0)

Great! I'll give 'em a try and thanks for pointing out the "index.html" tip! I'm for anything that can make future changes easier!

Thanks again, this forum has been a tremendous help!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved