Link to home
Start Free TrialLog in
Avatar of cjason
cjason

asked on

Mod ReWrite -- Allow ReWrite for most pages, disable ReWrite for selected few

On with my Mod ReWrite adventures...

Currently, I have a dynamic page in the root of my directory (shownews.php). Most of the pages in this root level are dynamic, so I have the following rewrite in my .htaccess file:

RewriteRule ^([^/]+)\.html$ /show_news.php?kw=$1 [L]]

So a url like http://www.domain.com/usa.html would really display http://www.domain.com/shownews.php?kw=us.

This works great. The problem is that I also have a contact page and a few other pages that fall victim to my mod rewrite. For example, a link to http://www.domain.com/contact.html (which is a real page) would lead to http://www.domain.com/shownews.php?kw=contact. My show news script then fails, because it doesn't recognize the category 'contact.'

So my question is this:
How can I add directives to my .htaccess file that will display actual pages and ignore my shownews ReWrite Rule for specific pages(e.g. Contact, About, etc.).

Any help is appreciated.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cjason
cjason

ASKER

Hi ramazanyich-

I tried your suggestion, but no avail. I think I might be misunderstanding where that Rewrite condition needs to go.

Here's my current .htaccess file:

========================================
Options -indexes

<Files .htaccess>
order allow,deny
deny from all
</Files>

RewriteEngine on

# Block this IP
RewriteCond %{REMOTE_ADDR} ^69\.95\.42\.202$
RewriteCond %{REQUEST_URI} !^/errordocs/error\.html$ [NC]
RewriteRule ^(.*) /errordocs/error.html [R]

# This is the key script of the site
RewriteRule ^([^/]+)\.html$ /show_news.php?kw=$1 [L]]
========================================

So as you can see, there is another RewriteCond thrown in there that I forgot to mention. When I tried your suggestion, I was getting internal server errors. Any ideas?
Avatar of cjason

ASKER

ramazanyich -

Got it working. There was something wrong with one of my own ReWrite statements. Your adivce was perfect. Thanks!