Forum Moderators: phranque

Message Too Old, No Replies

.htaccess - Redirect Everyone to New Domain Except My IP

htaccess redirect

         

raj2935

2:36 pm on Feb 19, 2011 (gmt 0)

10+ Year Member



I saw this old post in this forum which is somewhat similar to my problem but not exactly.

[webmasterworld.com...]

I do not have tech knowledge about mod rewrite, etc. So, I do not know how to change the mod rewrite statement mentioned in the above post to suit my requirement.


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
RewriteCond %{REQUEST_URI} !/alternate_page\.html$
RewriteRule \.html$ /alternate_page.html [R=302,L]


The above is the mod rewrite given in the earlier mentioned post.

But, what I need is this:

I have a static site at DomainName1 with .php pages and I plan to convert this site into a wordpress site.

So, till I create the WP site in DomainName1 and create all pages, etc., I would like to shift this static site to DomainName2 with a 302 redirect with the exception of my IP.

So, how do I modify the above mod rewrite statements accordingly.

Secondly, when people visit DomainName1/Page1.php, with the mod rewrite statements, will they be automatically transferred to DomainName2/Page1.php OR do I have to also separately include "Redirect 302 DomainName1/Page1.php DomainName2/Page1.php" for each of the pages in DomainName1

I would appreciate any help on the above points.

Thanks
Cheers
Raj

g1smd

6:59 pm on Feb 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Options +FollowSymlinks
RewriteEngine on


# Redirect index pages on "this" domain to www.example.com
# to the root or to a folder on the other site

RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
RewriteRule ^([^/]+/)*index http://www.example.com/$1 [R=302,L]


# Redirect all other pages on "this" domain to www.example.com
# retaining the original path in the new request.

RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
RewriteRule (.*) http://www.example.com/$1 [R=302,L]

raj2935

4:23 am on Feb 20, 2011 (gmt 0)

10+ Year Member



Hi G1smd,

Thanks a lot for your timely help.
I will implement it and will let you know if I run into any issues.

Cheers
Raj