views:

44

answers:

2

Hi all,

I've got an e-shop on a virtual server that's been used as a subdirectory for the last few years, but now I'm finally giving the VS it's own domain name. What I really need is visitors to the old URL to be transparently (and 301) redirected to the new URL with everything after /eshop/ maintained and apended to the new host.

I.e. http://www.example.com/eshop/page.php -> http://www.newdomain.com/page.php

Any help would be greatly appreciated.

A: 

You did not specify which web server you were using, but I assume its either apache or lighttpd.

In apache, you can use the Redirect keyword, e.g. Redirect 301 / http://www.newdomain.com/ I haven't tried this, but see e.g. here: http://www.yolinux.com/TUTORIALS/ApacheRedirect.html#APACHE It seems to work with .htaccess files as well.

In lighttpd, there is mod_redirect (and I did try this :) ): http://redmine.lighttpd.net/wiki/1/Docs:ModRedirect

EDIT: Redirect 301 /eshop/ http://www.newdomain.com

Krumelur
Hi Krumelur - thanks for your response, yep I've browsed a variety of .htaccess resources but I'm not too great with regex for getting the path correct, any ideas? I.e. as in the example above, I need to match the condition of: if http://www.example.com/eshop/$ is found, everything denoted by $ (following the URL) is copied and the visitor is 301 redirect to http://www.newdomain.com/$ where $ is the content we copied from the old URL...
Aaron
Have you tried the following?`Redirect 301 /eshop/ http://www.newdomain.com`That would redirect everything below eshop, e.g.`http://www.example.com/eshop/page1 -> http://www.newdomain.com/page1`
Krumelur
Wonderful, this worked perfectly, thanks!
Aaron
+1  A: 

This should work with Apache:

RewriteEngine On
RewriteBase /
RewriteRule ^/eshop(/.*)? http://www.newdomain.com$1 [R=permanent,L]

This redirects http://www.example.com/eshop/whatever to http://www.newdomain.com/whatever and also redirects http://www.example.com/eshop to http://www.newdomain.com

Jan Goyvaerts