Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a specific file from a rewriterule

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>
like image 366
Christian Avatar asked Dec 23 '12 01:12

Christian


People also ask

What is RewriteRule * F?

RewriteRule "\.exe" "-" [F] This example uses the "-" syntax for the rewrite target, which means that the requested URI is not modified. There's no reason to rewrite to another URI, if you're going to forbid the request.

What is NC in Rewritecond?

NC = nocase means regardless of the case of the incoming referrer traffic match with the given pattern. See Apache [NC|nocase] flag.

What is Rewritecond in htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.


1 Answers

To exclude a file, try something like this:

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

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

like image 191
Felipe Alameda A Avatar answered Sep 28 '22 11:09

Felipe Alameda A