Forum Moderators: phranque

Message Too Old, No Replies

Sitewide Redirect Because of Development Problems

Is this an appropriate case for a 302 redirect?

         

jlander

3:23 pm on Apr 22, 2010 (gmt 0)

10+ Year Member



Because of the new PCI Compliance standards, I have been forced into a total site redesign. I've switched shopping carts and from a windows/ASP to UNIX/PHP. My new site is almost ready. I say almost because it works fine on the test domain, but when I switched the name servers over I found several issues that broke the shopping cart. I switched the name servers back.

The problem is that when I do it again, my visitors will either see a broken cart...REAL BAD, or a white screen message that the site is down for maintenance...REAL REAL BAD.

When I switch the name servers back, I was thinking of doing an IP redirect in .htaccess that will allow the site developers access to the new site, but redirect customers back to the old site which will be on a new domain.

My question is, what type of redirect should I do? 301 is not appropriate. Is this a case where a 302 is?

jlander

8:30 pm on Apr 22, 2010 (gmt 0)

10+ Year Member



Here is a set of rewrite rules that I've come up with. They work the way I wanted, but I was wondering if this is the best way to do it?

    # Enable for server Maintenance
    # My Comcast IP Address: 1.2.3.4
    # Developer: Toucan IP Address: 5.6.7.8
    RewriteCond %{REMOTE_ADDR} !^(1\.2\.3\.4|5\.6\.7\.8)$
    RewriteRule ^([^/]*/)*(([^.]+\.)+(asp|php|s?html?))?$ http://www.example.com%{REQUEST_URI} [R=302,L,NC]

dmwaff

12:12 am on Apr 23, 2010 (gmt 0)

10+ Year Member



You were not very clear as the the Listen address of the two sites. I assume you are swinging DNS address and CNAME records to a new IP of the UNIX.

PROD www.example.com IP aaa.bbb.ccc.ddd ASP/windows
NEW --- IP aaa.bbb.ccc.eee UNIX

If you already have connectivity directly by IP then override www.example.com in your local host (windows or unix) with the IP of the UNIX interface and test like real world. Certify and then DNS cut over the example.com domain to the new IP for go-live.

aaa.bbb.ccc.eee www.example.com example.com

jdMorgan

12:38 am on Apr 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




RewriteCond %{REMOTE_ADDR} !^(1\.2\.3\.4|5\.6\.7\.8)$
RewriteRule ^(([^/]*/)*(([^.]+\.)+(asp|php|s?html?))?)$ http://www.example.com/$1 [R=302,L,NC]

would be a bit more compact, but equivalent.

Either version redirects only .asp, .php, .shtml, .shtm, .html, .htm, files and 'directory index' pages in any and all directories to the other domain. It will not redirect any image, css, JS file, document, or media file requests. Is that what you want?

Jim

jlander

1:43 am on Apr 23, 2010 (gmt 0)

10+ Year Member



Jim,

Thanks for the code improvement. Originally I tried the $1 and I couldn't get it to work. It redirected everything to the homepage and if there was dynamic content, it redirected to www.example.com/?some=thing. Those extra () fixed it. Your rules work. Thanks.

I read other threads on WebmasterWorld that there is no need to redirect other file types, but after reflection, I think that pertained to redirects on the same website. I guess I should use these to redirect all requests since I'm redirecting to a different website.

RewriteRule ^(.*)$ http://www.example.com/$1 [R=302,L,NC]