unique .htaccess question about mod_rewrite and RewriteCond
        Posted  
        
            by Stephen
        on Server Fault
        
        See other posts from Server Fault
        
            or by Stephen
        
        
        
        Published on 2010-03-31T23:57:29Z
        Indexed on 
            2010/04/01
            0:03 UTC
        
        
        Read the original article
        Hit count: 449
        
I have a few rewrite rules like these
RewriteRule ^dir/(.*)-something.html otherdir/file1.php?var1=val&var2=$1 [L,NC]
RewriteRule ^dir/ otherdir/file2.php?var1=val [L,NC]
dir/ is not a real directory. Everything above works as expected.
However, the user is able to type anything like
mysite.com/dir/asdfasdfasdfsdf
And they are still redirected to file2.php. If the user types in just garbage I'd like to serve a 404 instead.
I'm guessing I need a RewiteCond that will test for blank space after the slash and only then serve file2.php, but I'm unsure how to write it.
© Server Fault or respective owner