.htaccess

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. :slight_smile:

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:


ErrorDocument 403 [COLOR="#0000CD"]/redirect-folder/[/COLOR] 
Order deny,allow 
Deny from all 
Allow from [COLOR="#FF0000"]111.222.333.444[/COLOR]

So, /redirect-folder/ would be the folder you redirect everyone to, and the bit in red is your own IP address.

This is not my area, though, so I may get shot down for this! But I can take it. I’m happy to learn. :slight_smile: 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.

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?):

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

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.

Regards,

DK