Solved

Create an exception to a mod_rewrite using rewritecond

Posted on 2009-03-30
2
368 Views
Last Modified: 2012-06-21
Okay, so I have this mod rewrite that checks to see if a folder or file exists, then if not, converts the URL into a string that gets sent to index.php. This is working great, I just want to create an exception that when it detects anything with /wp as in /wp/category/ or /wp/about, pretty much anything that starts with /wp, it will not execute the rule. Below is the version that works and the versions I tried to do.
// this works

Options +FollowSymLinks

RewriteEngine On

RewriteBase /
 

#SEFU

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php?url=%{REQUEST_URI} [L,NE]
 

// this is my attempt that didn't work

Options +FollowSymLinks

RewriteEngine On

RewriteBase /
 

#SEFU

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/wp/

RewriteRule .* index.php?url=%{REQUEST_URI} [L,NE]

Open in new window

0
Comment
Question by:MeridianManagement
2 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 24027258
You can't use the lexicographical eq. operator (=) if you'd like to match /wp/foo. =/wp/ will only match /wp/ but not /wp/anything:
// this is my attempt that didn't work

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

 

#SEFU

RewriteCond %{REQUEST_URI} !^/wp/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^.* index.php?url=%{REQUEST_URI} [L,NE]

Open in new window

0
 
LVL 2

Author Closing Comment

by:MeridianManagement
ID: 31564679
thank you!!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Read about why website design really matters in today's demanding market.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now