Forum Moderators: phranque

Message Too Old, No Replies

301 mod_rewrite

         

mike2

4:44 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



Here is a little problem that I am sure someone has got the answer to...if only it were me!

I have a website (myoldsite.com) and I want to redirect all files to my new site (mynewsite.com) using mod_rewrite in .htaccess i.e:

RewriteEngine On

RewriteRule ^(.*)$ [mynewsite.com...] [R=301,L]

However, these is one directory on my old site (myoldsite.com) that I want to be able to access without the redirect. This happens to be the cgibin which holds many perl scripts that I can't for various reasons move to the new site. (Some of the scripts have been bought and will only work within www.myoldsite.com)

Any ideas how this can be achieved?

ChadSEO

4:51 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



If you add a condition in there, you should be able to exclude the cgi-bin directory, I believe something like this should work:


RewriteEngine On
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [R=301,L]

[edited by: jdMorgan at 5:20 pm (utc) on Aug. 4, 2005]
[edit reason] Fixed [ code ] formatting. [/edit]

mike2

8:49 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



Cheers for that.

We will give it a try.