I need .htaccess code that will:

Restrict a specific IP from a specific page.
Allow that IP on any other pages but the restricted one.

I already tried this and it does not work:

<files submit.php>
order allow,deny
deny from 1.2.3.
deny from 1.2.
allow from all
</files> 

Does anyone know a better way, maybe using mod_rewrite?

Recommended Answers

@vectro

Does anyone know a better way, maybe using mod_rewrite?

How did you came up with that?

You know it also depend on your host server too.

Read this:

https://my.justhost.com/cgi/help/htaccess#deny-ip

Also …

Jump to Post

All 2 Replies

I thought of using mod_rewrite is an alternative if 'deny from' wasn't working. It turns out I had a bad Apache build. When I rebuilt Apache, the 'deny from' code I posted in the first place ended up working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.