14

I have a site which uses htaccess in order to use nice URLs. However I want the htaccess file to leave alone a whole folder and it's content completely. The content of my htaccess file is:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

How should I complete the above code to EXCLUDE completely the folder named "admin"

Many thanks in advance!

user1185551
  • 217
  • 1
  • 2
  • 12
  • http://stackoverflow.com/questions/1848500/htaccess-mod-rewrite-how-to-exclude-directory-from-rewrite-rule and http://stackoverflow.com/questions/1715785/exclude-htaccess-for-admin-folder?rq=1 probably can help. While you making the question look at the other articles stackoverflow gives and look around first. – JochemQuery Dec 12 '12 at 10:25
  • 1
    I tried to modify the code based upon your second link, but unfortunately didn't work. The modified code looked like: RewriteEngine On RewriteRule ^admin($|/) - [L] RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 – user1185551 Dec 12 '12 at 10:33
  • I think I can't help you any further because of my knowledge of htacces isn't that great. You can put your edit code in your main question. So other people see what you have tried and maybe google on something like exclude map htacces. – JochemQuery Dec 12 '12 at 10:39

3 Answers3

23

You could also put a new .htaccess file in the folder you want to ignore, saying:

RewriteEngine Off
Albert-Jan Verhees
  • 2,084
  • 1
  • 16
  • 19
17

Where the folder you want excluded is /excluded-folder/ you would add the following rule:

RewriteCond %{REQUEST_URI} !^/excluded-folder/.*$

before the other two RewriteConds you have listed.

Wige
  • 3,788
  • 8
  • 37
  • 58
0

I had problems with PhpMyAdmin in a subdirectory of TYPO3. After long time I found this block in a .htaccess-file in a directory above causing malfunction of one file of phpmyadmin:

# UTF-8 encoding
AddDefaultCharset utf-8
<IfModule mod_mime.c>
    AddCharset utf-8 .atom .css .js .json .manifest .rdf .rss .vtt .webapp .webmanifest .xml
</IfModule>

Reason for this was that there exists a file phpmyadmin.css.php which is triggered by the rule.
After changing the rule like following PhpMyAdmin is working normally:

# UTF-8 encoding
AddDefaultCharset utf-8
<IfModule mod_mime.c>
    AddCharset utf-8 .atom .js .json .manifest .rdf .rss .vtt .webapp .webmanifest .xml

    #####
    ## This block is for the file phpmyadmin.css.php, where the suffix css is not the last one.
    ## @see https://httpd.apache.org/docs/current/mod/mod_mime.html#multipleext
    #####
    <FilesMatch "[^.]+\.css$">
      AddCharset utf-8 .css
    </FilesMatch>
</IfModule>

The condition <FilesMatch "[^.]+\.css$"> is only triggered if the suffix css is at the end of the filename.

So my case is not about rewriting but about a resembling problem where rewriting seemed being the solution first for me.

David
  • 5,882
  • 3
  • 33
  • 44