homepage Welcome to WebmasterWorld Guest from 54.234.67.55
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library : Charter : Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess-redirect all but my IP
geoffb




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

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

 

g1smd




msg:4450766
 11:13 am on May 8, 2012 (gmt 0)

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

What have you tried so far?

geoffb




msg:4450775
 11:41 am on May 8, 2012 (gmt 0)

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]

g1smd




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

$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.

geoffb




msg:4450784
 12:27 pm on May 8, 2012 (gmt 0)

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

g1smd




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

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.

geoffb




msg:4450795
 1:01 pm on May 8, 2012 (gmt 0)

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

g1smd




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

What do other users see?

Have you tested it to be sure?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved