Not sure if this is the correct throead to post this but, how can I go about and changing my .htaccess to where only I would see a certain page, and everyone else is redirected to another page?
| SitePoint Sponsor |
Not sure if this is the correct throead to post this but, how can I go about and changing my .htaccess to where only I would see a certain page, and everyone else is redirected to another page?


Off Topic:
Thread moved to Server forum.![]()
This may be a display of total ignorance on my part, but the one way I sort of know to do that would be to put a .htaccess file inside the folder you don't want people to see, and insert code something like this:
So, /redirect-folder/ would be the folder you redirect everyone to, and the bit in red is your own IP address.Code:ErrorDocument 403 /redirect-folder/ Order deny,allow Deny from all Allow from 111.222.333.444
This is not my area, though, so I may get shot down for this! But I can take it. I'm happy to learn.This will only suit you if the page you don't want people to see is in a folder of its own, too. I'm sure there will be other solutions if you need something else. Maybe even PHP would be the way to go.
Last edited by ralph.m; Apr 30, 2012 at 02:10.
Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form
Try your hand at the new JavaScript Challenge!
If you don't like getting your feet stuck in a bog, avoid Twitter BootsTrap.

Ralph,
I think you've got a start on the correct answer (wouldn't you have to specify the <Files>?) but offer my initial thought about using mod_rewrite (surprise, eh?):
Of course, you can use any Apache variable to identify yourself to mod_rewrite (the {REMOTE_ADDR} will match your accessing IP address) and you'll need to identify the private and alt pages and use the correct regex for private and actual URI (relative to the DocumentRoot if this .htaccess is in the DocumentRoot). I've suggested the R=301 flag so you can see the redirection during testing but you should remove it so visitors will not be aware of the redirection.Code:RewriteEngine on # Identify yourself via some Apache variable like RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.2$ RewriteRule ^private_regex$ alt.page [R=301,L] # Remove the R=301, after testing to hide the redirection
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