how do I write an exception to a rule?

New to mod_rewrite? This is a good place to start.

how do I write an exception to a rule?

Postby fredmett » Mon Sep 14, 2009 12:34 pm

Hi,

I just started using mod_rewrite today and I am mostly lost. I understand the concept and I have read through some of the forum but I have not found what I needed yet. My brother has a site he got built by someone, and it hat the following .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~myfiles/
RewriteRule ^windows/(.+).php /index.php?page=$1 [QSA,L]
RewriteRule ^articles/(.+).php /index.php?page=articles&article=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.php index.php?page=$1 [QSA,L]
</IfModule>

Then in the index.php file it takes the actual page stored in the inc/pages and wraps the header footer ect around the content in the specific page. Now I was trying to add a google map, and some ajax functionality that I know works on other sites. But I needs those php files not to get wrapped with the index.php code. How can I write an exception to say the folder inc/pages/map_files so I can store my files there and call them in an iframe in file in inc/pages?
fredmett
 
Posts: 1
Joined: Mon Sep 14, 2009 12:18 pm

Postby richardk » Tue Sep 15, 2009 5:49 pm

A normal match with ! at the beginning for "not".

Code: Select all
Options +FollowSymLinks

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^windows/(.+)\.php$  /index.php?page=$1                  [QSA,L]
  RewriteRule ^articles/(.+)\.php$ /index.php?page=articles&article=$1 [QSA,L]

  RewriteCond %{REQUEST_URI} !^/inc/pages/map_files(/.*)?$ [NC]
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^(.+)\.php$ /index.php?page=$1 [QSA,L]
</IfModule>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 40 guests

cron