how do I accomplish these two? I just can't seem to get it right... What I want to do is to just allow myself access to the site and redirect everyone else to the construction page (my site is under construction)
| SitePoint Sponsor |
how do I accomplish these two? I just can't seem to get it right... What I want to do is to just allow myself access to the site and redirect everyone else to the construction page (my site is under construction)

HK,
Please specify what you want to redirect to ... or correct this generic codeThis will only allow the localhost (127.0.0.1) to access the directory and all subdirectories but redirect everyone else to example.com - fill in the correct IP address and redirection.Code:RewriteEngine on RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$ RewriteRule .? http://www.example.com [L]
Regards,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Sorry it took me so long to reply (situations in real life came up) anyway, I tried that code but it gave me "This webpage has a redirect loop" so what do you suggest?

Why would you redirect? This seems like a perfect place to use Allow and Deny to me
This will show the website when accessed from your IP, and show a "403 forbidden" page to everyone elseCode:Order Deny,Allow Deny from all Allow from yo.ur.i.p
![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
but my site is under construction right now, so I was wanting to show the visitors an under construction page.

In that case you might want to have a look at this, where your exact problem is described and solved![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
I'm not sure what I'm doing wrong, cause it's still not working...

What code do you have now?
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Well I have a feeling that I have the IP wrong now, but I'm using the IP that's mentioned at whatsmyip.org, but yet it redirects me?

Yes that IP is the one you're using to visit your website -unless you have a really strange setup.
What is the code you have now? Feel free to mask out your IP, i.e., w.x.y.z or something.
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Well I finally got the redirect working, but now my CSS and images aren't working, the CSS will work for the maintenance page, but images won't work on it. This is the code I'm using now:
I found this code off of htaccess Redirect to Maintenance PageCode:# MAINTENANCE-PAGE REDIRECT <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REMOTE_ADDR} !^this\.is\.my\.ip RewriteCond %{REQUEST_URI} !/construction.html$ [NC] RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC] RewriteRule .* /construction.html [R=302,L] </IfModule>

If you want css to work too you should modify it as follows
Also, you can get rid of the <IfModule mod_rewrite.c> and </IfModule> once you've established mod_rewrite is installed and working, no need to ask that again and againCode:# MAINTENANCE-PAGE REDIRECT <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REMOTE_ADDR} !^this\.is\.my\.ip RewriteCond %{REQUEST_URI} !/construction.html$ [NC] RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css)$ [NC] RewriteRule .* /construction.html [R=302,L] </IfModule>![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Well it finally works nowbut now I have another question, it's concerning the redirect from earlier, i found out why I had such trouble from it, because I was testing it on another computer from within my house, and once I tried it on a proxy site, the redirect worked, I then realized that all of the computers in my house share the same public IP but just different LAN IPs, but I tried using my LAN IP in the .htaccess file, and it redirected me (which is not what I want), so how can I redirect all the computers in the house and everybody else in the world? (though I already accomplished the everybody in the world part lol)

It's the public IP that you should filter. The internal LAN IP shouldn't match at all (because that's hidden behind NAT). Are you saying it does?
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Well I'm saying that the other computers in the house have the same public IP according to whatsmyip.org so their not getting redirected like I would want them to.

Ah okay. Yes, you can't do that. Have you considered installing a web server on your own PC for development purposes? That's also nicer because it's all local and thus faster and you don't have to upload files all the time![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Actually that's what I've been doing for some time now, I just uploaded the files to make sure everything would run smoothly once I got the website running (though I've still got a long way to go lol)

Although I'm a day late and a dollar short, the way I do it is to use DirectoryIndex public_link private_link so that the public only see the public link (index.html) while I link directly to the private_link (index.php). That way, I can have visitors see the "under construction" notice while I can see (and provide links for my clients) the "work in progress."
Regards,
DK
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
Bookmarks