My question is this - is there any way to redirect everyone to the new domain (just like in the code above) except for my IP? Is there some conditional statement that I can use?
i know you can achieve this with php if that helps. Not sure about apache. Here is the php code regardless.
PHP Code:
if (!$_SERVER['REMOTE_ADDR']="84.63.49.192") // Replace with your IP
header('Location: http://www.tutwow.com');
That would go at top of page.
Anther solution would be to add http://www.tutorialwow.com as a server alias to http://www.tutwow.com/ which would take /contact/ and everything. Though the URL would still look like the old one but would actually be on the new site. Or setting up both virtual hosts document root to the same location. Either way then you could set up a new subdomain for the old site. Then using htaccess to only allow your IP to access that subdomain.
__________________
You can not say you know how to do something, until you can teach it to someone else.
However, I think I can only use htaccess because I can't put PHP on every page on the site. The thing is, I just need to be able to access the site while other people are being redirected. Isn't there some conditional statement in htaccess?
There is another way you can use IP blocking with your htaccess that will give a 403 error if the user is not on the IP secified. Then rather than using the standard 403 document you can redirect them to a different one with the following command.
Code:
ErrorDocument 403 /newerrordoc.html
Then in that page 'newerrordoc.html' you can put an html redirect command
Options +FollowSymLinks
RewriteEngine On
# If it's not your IP address
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
# Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine On
# If it's not your IP address
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
# Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Ok, that's more like what I was looking for.
I'm guessing my IP would go where the "1\.2\.3\.4" is, right?
This wouldn't work with subdomains, though, would it?
I'm guessing my IP would go where the "1\.2\.3\.4" is, right?
Yes.
Quote:
This wouldn't work with subdomains, though, would it?
Do you mean abc.example.com to abc.example.net and def.example.com to def.example.net?
Code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$
# Match the sub domain (if there is one).
RewriteCond %{HTTP_HOST} ^(.+\.)?example\.com$ [NC]
# %1 is the sub domain (or empty).
RewriteRule ^(.*)$ http://%1example.net/$1 [R=301,L]
For some reason, the code isn't working for me. I put in my IP address, keeping the code exactly like you had it, and put it in the htaccess file, but I still get redirected to tutwow.com. Any thoughts?
Ok, that was my problem. When I did an "ifconfig" on my mac, it must have given me a wrong IP address for some reason. I changed the IP in the code, and it works perfectly now.