I am working on a new website, and am setting up the new site on a new linux/apache server. I want to redirect our new friendly URL to the existing site (that has a horrible URL) while I work on the new site. This of course means I want to find some way to view the new development site with the new friendly URL while I develop it, but let the rest of the world be redirected... is this possible? Perhaps by singling out my static IP or something in the rewrite conditions?
the way i have mine set up at the moment (same situation as you with the horrible and nice domains!) is that the nice one redirectswhen index.php or the default page is requested. So i can view the new site by typing www.domain.co.uk/indexnew.php. Didn't even use htaccess. just used headers from php. It's only temporary anyway..... Ned
I'm actually thinking of getting a development subdomain, and just making all of the links relative (or possibly based on the url being used to access it.). then I could just use .htaccess to redirect all requests to foo.example.com to www.example.com/~foo but all requests to devfoo.example.com would go through just fine. I also need to make foo.example.com/bar go to www.xample.com/~barsite If anyone could shed a little light on how to do this, I'd be really appreciative! (oh and since I'm trying to clean up some of my code, and I want it to be as quick as possible, I'm trying to avoid using a PHP script, but that's also because I want to know how to do it via .htaccess so I can learn something new )
Okay, apparently the .htaccess things I was trying were good, but my apache2 configuration was bad, so now that I have .htaccess working and mod_rewrite working: Assume this file is on a server that has 2 subdomains: foo and foodev Code: RewriteEngine on #first filter out all foodev.example.com requests: RewriteCond %{HTTP_HOST} !^foodev.example.com$ #now filter out all requests from the IP 111.222.333.444: RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444 #now filter out all requests for foo.example.com/bar : RewriteCond %{REQUEST_URI} !^/bar #now rewrite the URL based on the above restrictions: RewriteRule (.*) http://www.example.com/~foo/ [R,L] #once again filter otu foodev.example.com requests: RewriteCond %{HTTP_HOST} !^foodev.example.com$ #and still filter out the chosen static IP RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444 #now redirect the user! RewriteRule (.*) http://www.example.com/~barsite/ [R,L] So what this does is redirects: foo.example.com/and/anything/else to www.example.com/~foo/ BUT It catches foo.example.com/bar/and/anything/else and redirects those to: www.example.com/~barsite And: It doesn't do anything if it is coming from the IP 111.222.333.444 (which I set to my static IP) And it also won't do anything if I request foodev.example.com, but I need to get that subdomain pointed at the server before that works. viola!