Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
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 7 '09 at 18:16

2 Answers 2

up vote 2 down vote accepted

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]
share|improve this answer
    
Or, for the last line, to NOT change the URL in the browser: RewriteRule . a.php –  Arjan Sep 8 '09 at 7:36

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.

share|improve this answer
    
I'm also not sure if you need the slash in the RewriteCond if you're using RewriteBase. Try it both ways. –  Devin Ceartas Sep 7 '09 at 18:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.