Welcome to WebmasterWorld Guest from 54.145.136.73

Forum Moderators: Ocean10000 & incrediBILL & phranque

htaccess-redirect all but my IP

   
10:39 am on May 8, 2012 (gmt 0)

5+ Year Member



Hi,

I have a directory name /development which I dont want my client to see whilst I develop a wp cms site.

I have a holding page at the root in an index.html filename and would like to redirect anyone except my IP to the root holding page.

Any help really appreciated.

Thanks
geoffb
11:13 am on May 8, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



It's two (perhaps three) lines of code, using a RewriteCond (or two) and a RewriteRule.

What have you tried so far?
11:41 am on May 8, 2012 (gmt 0)

5+ Year Member



Hi g1smd

I have tried:

RewriteEngine on
RewriteCond $1 !^http://www.mysite.com/development
RewriteCond %{REMOTE_HOST} !^00\.00\.00\.00
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

[edited by: incrediBILL at 12:35 pm (utc) on May 8, 2012]
[edit reason] fixed URL w/example.com [/edit]

12:11 pm on May 8, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



$1 will never contain protocol or hostname nor slash after hostname.

Use example.com in code snippets in this forum.

I thought you wanted to redirect to a specific page? Your code doesn't do that.

You should check (with a RewriteCond) that the user is not requesting the redirected-to page otherwise (.*) will match again and create an infinite redirect loop.

You should serve "503 Unavailable" to Google and others until you're ready to go.
12:27 pm on May 8, 2012 (gmt 0)

5+ Year Member



Hi,

So would this not work:

RewriteEngine on
RewriteCond $1 !^development
RewriteCond %{REMOTE_HOST} !^00\.00\.00\.00
RewriteRule (.*) http://www.example.com/index.html/$1 [R=301,L]

Thanks
12:50 pm on May 8, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Use the Live HTTP Headers extension for Firefox to test it.

You'll likely see an infinite loop with the target URL getting longer and longer.

This is also one of those rare cases where a 302 redirect might be in order.
1:01 pm on May 8, 2012 (gmt 0)

5+ Year Member



Hi g1smd,

Thanks, I sorted it with a 302 redirect like you said.

I only want it as nearing completion i clicked on a link I built in the footer and went to the client site, this development domain link will now show on the clients Google Analytics so i just wanted to send anything back than the website for them if they see my link and go to have a look. Now only my IP serves up the site while I finish off.

thanks for the tip.

geoffb
2:02 pm on May 8, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



What do other users see?

Have you tested it to be sure?
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month