19

I have been here: How to exclude a specific file in htaccess

and here: exclude files from rewrite rule in .htaccess

but neither worked. What might I be doing wrong?

.htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-content(/.*|)$ - [L] # don't take any action
RewriteRule ^wp-admin(/.*|)$ - [L] # don't take any action
RewriteRule ^wp-includes(/.*|)$ - [L] # don't take any action
RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$

RewriteRule ^moreinfo/(.*)$ http://www.kgstiles.com/moreinfo$1 [R=301]
RewriteRule ^healthsolutions/(.*)$ http://www.kgstiles.com/healthsolutions$1 [R=301]
RewriteRule ^(.*)\.html$ $1/ [R=301]
RewriteRule ^(.*)\.htm$ $1/ [R=301]
</IfModule>
2
  • ¿Rewrite from what to what? Some examples please. From your rule set it's impossible to guess. Dec 23, 2012 at 1:59
  • I want to exclude a specific file from the rest of my rules. I'll post my htaccess file in an edit above.
    – Christian
    Dec 23, 2012 at 2:04

1 Answer 1

43

To exclude a file, try something like this:

RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$ 

The rule will be skipped if the file is pureplantessentials.html.

8
  • it is still rewriting. Is there a specific place it should be? I put it at the end of my exclusions...
    – Christian
    Dec 23, 2012 at 2:22
  • That's why an example is important. Please update your answer with an example to see how the incoming URL with the file to exclude looks. Dec 23, 2012 at 2:25
  • Should I post my updated .htaccess file and show you how it looks?
    – Christian
    Dec 23, 2012 at 2:35
  • I just posted my htaccess file in my question. www.kgstiles.com/pureplantessentials.html still redirects to www.kgstiles.com/pureplantessentials/
    – Christian
    Dec 23, 2012 at 2:37
  • 1
    I'm not sure if it was a mistake by you or if something I did was contrary to what I said above, but by changing RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$ to RewriteCond %{REQUEST_URI} !^pureplantessentials\.html$ (without the first /), I was able to make this work.
    – Christian
    Jan 16, 2013 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.