homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess with Directory Exception
How to tell .htaccess to not handle specific directories
wfernley

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3530163 posted 11:44 am on Dec 18, 2007 (gmt 0)

Hey everyone,

Does anyone know how I can get my .htaccess file to control every directory within root except for specific directories that I specify.

Here is my current code:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST}!^(www\.¦$) [NC]
RewriteRule ^ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]

# Change ---.php to ---.html
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule (.*) pages\.php?page=$1

I basically have every file being requested to go to pages.php unless the file actually exists. I have a directory (we will call it "testdir") which I want to exclude in the .htaccess file so when someone requests a file within the testdir directory, the .htaccess file does not try to forward it to pages.php.

Can anyone help?

Thanks in advance for your help!

Wes

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3530163 posted 2:20 pm on Dec 18, 2007 (gmt 0)

Add a RewriteCond with a negative pattern to exclude that directory.

RewriteCond %{REQUEST_URI} !^/testdir/

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved