0

I have an application most of it is still in development that's why i need to block access on all pages but just not two of them.

Suppose i have a.php all requests will be redirected to here except b.php.

So i think there should be 3 rules:

1st: when a.php and b.php are requested they should be visible to user,

2nd: if anything other than those two is requested, 
     it should be redirected to a.php.

3rd: for external css,javascript and image files 
     there should be an access rule

Since i dont have much experience with server administration, i believe i'm totally lost:)

This is what i tried:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !^/b.php
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ a.php
Sinan
  • 227
  • 3
  • 6
  • As for "most of it is still in development": are you sure you don't actually want something that requests for authentication if any file other than a.php or b.php is requested? – Arjan Sep 07 '09 at 18:16

2 Answers2

2

I'm not completely sure what "there should an access rule" means for point 3 so I'm taking it as "permit access to files with these extensions".

I think this does what you're asking for but that might not be what you want -- you're effectively going to stop anything besides JS/CSS/etc, a.php and b.php from being reachable, which is probably not much use.

# permit JS, CSS, etc
# - means don't rewrite the URL
# [L] means stop processing rules
RewriteRule \.(js|ico|txt|gif|jpg|png|css)$ - [L]

# Permit a.php and b.php
RewriteRule ^/[ab]\.php$ - [L]

# HTTP 302 redirect anything else to a.php
RewriteRule ^ http://your.server/a.php [R]
markdrayton
  • 2,449
  • 1
  • 20
  • 24
1

Well, for one thing, you need to add a.php to the RewriteCond (a|b).php or else you've created an endless loop where a.php is always redirected to itself.

Devin Ceartas
  • 1,478
  • 9
  • 12