gethan

msg:1514685 | 10:59 am on Feb 6, 2002 (gmt 0) |
Hi Bill .htaccess in your english dir. [perl] rewriteEngine on rewriteRule ^/english/(.+) [newdomain.com...] [L,R=301] or rewriteEngine on rewriteBase /english/ rewriteRule ^(.+) [newdomain.com...] [L,R=301] [/perl] Will do what your looking for. The caveat with using the method you list, is that bookmarks and links (non-homepage) would all be redirected to the new homepage. mod_rewrite saves you have to do this for every page. I recently moved my entire site from .com to .co.uk - I'll let you know what happens to rankings as a result.... so far the spiders have all gone to the right places - will my PR follow through ;)
|
sugarkane

msg:1514686 | 3:44 pm on Feb 6, 2002 (gmt 0) |
You could also do it with mod_alias, which has less overhead than mod_rewrite. In your .htaccess on your original site: RedirectMatch 301 /english/(.*\.html)$ htt*://www.newsite.com/$1
|
bill

msg:1514687 | 2:04 am on Feb 7, 2002 (gmt 0) |
Wow. Thanks for the help. This place never ceases to amaze me. So the redirectPermanent method I outlined above now looks much more cumbersome...I'd have to map each page to its new location if I didn't want to simply redirect people to the new home page. Thanks for clearing that up for me. Please confirm if I'm understanding this correctly. If I use the mod_rewrite or mod_alias methods above, any page under the relative subdirectory will be redirected to the exact same page only on the new domain. htt*://www.oldsite.co.jp/english/a.html --> htt*://www.newsite.com/a.html htt*://www.oldsite.co.jp/english/a/b.html --> htt*://www.newsite.com/a/b.html htt*://www.oldsite.co.jp/english/a/b/c.html --> htt*://www.newsite.com/a/b/c.html sugarkane I hadn't really looked at this mod_alias option before. In your example I see (.*\.html), would this need to be modified for files like .htm, or PDFs or others?
|
deltab

msg:1514688 | 5:41 am on Feb 7, 2002 (gmt 0) |
Bill: You got it right the first time - a simple RedirectPermanent will do what you want. See the Apache docs on mod_alias [httpd.apache.org] for details and an example. (Note that the Redirect directives are provided by mod_alias.) The suggestions by others will also work, but they're overpowered for this particular need. A demonstration: one of my customers expanded his Scream Machines site to include other roller coaster games, and changed the name to suit. I put this into his Apache conf file: <VirtualHost 123.456.789.123> ServerName www.olddomain.com ServerAlias olddomain.com Redirect permanent / http://newdomain.net/ </VirtualHost>
Now if you request <http://olddomain.com/anything/you/like/here/>, you'll be redirected: GET http://olddomain.com/anything/you/like/here/ --> 301 Moved Permanently GET http://newdomain.net/anything/you/like/here/ --> 404 Not Found
Notice how only a prefix of the requested URI was changed in the redirection: all the old URIs are automatically mapped to the corresponding new ones. It really is that simple - no RedirectMatch or RewriteRule needed. (If however he wanted the redirect to be to the new front page, I'd use RedirectMatch seeother ^/(.+)$ http://newdomain.net/. (303 See Other [w3.org] because the front page wasn't the one asked for.)) Hope this clarifies things. (edited by: DaveAtIFG at 7:41 pm (utc) on Feb. 7, 2002)
|
bill

msg:1514689 | 6:24 am on Feb 7, 2002 (gmt 0) |
deltab thanks for the help and welcome to WebmasterWorld. I guess my quandary now is which of these solutions is simplest and most universally applicable? The reason I say this is that although everything is hosted in-house now, very shortly even the root domain is going off to it's own server somewhere...and I'm only assuming they'll still be using Apache. deltab, I got some odd behavior with the sample you posted GET http://olddomain.com/anything/you/like/here/ --> 301 Moved Permanently GET http://newdomain.net/anything/you/like/here/ --> 404 Not Found
|
| With IE6.02 your redirect isn't working...at least on my machine. It worked with Opera 6, Mozilla 0.9.3, and NN4.7...just not my IE. In IE6.02 I'm getting http://olddomain.com/anything/you/like/here/ --> 404 and the redirect is not happening (I stay on the http*//olddomain.com domain) Your Apache conf file method doesn't involve .htaccess at all? (edited by: DaveAtIFG at 7:42 pm (utc) on Feb. 7, 2002)
|
sugarkane

msg:1514690 | 10:02 am on Feb 7, 2002 (gmt 0) |
deltab - yep, that'd work if you wanted to redirect the whole site to a mirror, but in bill's case the match rule is needed as (if I read it right) different parts of the site will be redirected to different domains, so a bit more control is necessary. > (.*\.html), would this need to be modified for files like .htm Yes - you can modify it to whatever filetype you want. You could even just use /english/(.*)$ to match absolutely anything below the 'english' directory.
|
gethan

msg:1514691 | 10:22 am on Feb 7, 2002 (gmt 0) |
Bill, I'd go with sugarkane's method for this one - I've been mod_rewrite mad for the last couple of months and have overlooked simpler options. If you do use the mod_rewrite method above - note I made a mistake and the + should be a *.
|
bill

msg:1514692 | 12:21 am on Feb 8, 2002 (gmt 0) |
If I use sugarkane's method I would place the .htaccess file in my current root directory, and then use it like this? [color=blue]RedirectMatch 301 /english/(.*\.html)$ htt*://www.newsite.com/$1 RedirectMatch 301 /chinese/(.*\.html)$ htt*://www.newsite.cn/$1 RedirectMatch 301 /french/(.*\.html)$ htt*://www.newsite.fr/$1 [/color]
|
sugarkane

msg:1514693 | 9:39 am on Feb 8, 2002 (gmt 0) |
Yup, that's it exactly bill.
|
bill

msg:1514694 | 11:58 pm on Feb 8, 2002 (gmt 0) |
Cool. This doesn't look all that hard now ;) sugarkane mentioned that I could use the following to redirect everything
[color=blue]RedirectMatch 301 /english/(.*)$ htt*://www.newsite.com/$1[/color]Would it be possible to modify this to just redirect for .html and .pdf files?
|
Gorufu

msg:1514695 | 1:09 am on Feb 9, 2002 (gmt 0) |
G'day Bill, > Would it be possible to modify this to just redirect for .html and .pdf files? the following should do the trick RedirectMatch 301 /english/(.*\.(html¦pdf))$ htt*://www.newsite.com/$1 Please note: ¦ is the pipe symbol. If you copy and paste the code the pipe symbol will need to be hand edited.
|
bill

msg:1514696 | 4:12 am on Feb 9, 2002 (gmt 0) |
Thanks Gorufu. I think I'm ready to go out and wreak havoc on this company's sites. I have just enough knowledge to do some damage...of course I'll be back if I mess anything up ;) Thanks everyone
|
wilderness

msg:1514697 | 4:00 pm on Feb 10, 2002 (gmt 0) |
<RedirectMatch 301 /english/(.*\.(html¦pdf))$ htt*://www.newsite.com/$1 > Is it possible to configure this to some sort of NULL to specify a 410 code? Thanks in advance
|
deltab

msg:1514698 | 5:35 pm on Feb 10, 2002 (gmt 0) |
wilderness: Yes. According to the docs [httpd.apache.org] the following should work:
Redirect gone /old/path/prefix
I've never used that though.
|
wilderness

msg:1514699 | 5:59 pm on Feb 10, 2002 (gmt 0) |
I have some pages that have been <gone> for nearly two years which still get requests from the search engines. Which results in a crazy circle between SE's and visitors. I've had replacemt pages which are nearly blank specifying 410 that the page has been permanently removed and yet access continues. Many thanks
|
|