0

I have another application running in a directory called "calculator" and I can't seem to get EE to ignore it. When I point to the url /calculator I get a 404.

I have this in my htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !calculator/
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

I also tried changing these two lines:

RewriteCond %{REQUEST_URI} !calculator/
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]

To:

RewriteCond $1 !\.(gif|jpe?g|png|calculator)$ [NC]

Any ideas on what I'm missing here?

I double checked to make sure I don't have any url's "calculator" as well.

EDIT/Added:
- .htaccess in /calculator directory

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteBase /
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

# Force the latest IE version, in various cases when it may fall back to IE7 mode 
# github.com/rails/rails/commit/123eb25
# commitcomment-118920 
# Use ChromeFrame if it's installed for a better experience for the poor IE folk 
<IfModule mod_setenvif.c> 
  <IfModule mod_headers.c> 
     BrowserMatch MSIE ie 
     Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie 
  </IfModule> 
</IfModule>
2
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !(calculator) [NC]
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Explainations...

RewriteCond %{REQUEST_URI} !calculator/

I think the problem here is that you're not informing it what to ignore by framing in brackets. Also you're specifying the trailing backslash, but that isn't part of the request.

RewriteCond $1 !\.(gif|jpe?g|png|calculator)$ [NC]

This won't work because it's looking for extensions - note the \. at the beginning of the condition, you're also terminating it with the $, so nothing after it will be matched (/ or filename in the folder). Instead it should be:

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond $1 !(calculator) [NC]

This should have worked...

RewriteCond %{REQUEST_FILENAME} !-d

But maybe not if you have a trailing slash (according to this post: https://stackoverflow.com/questions/163302/how-do-i-ignore-a-directory-in-mod-rewrite), also I doubt it's the complete request (to access that folder), as I expect you're accessing some file under that folder which may be why the condition isn't matching?!?!

UPDATE

The issue raised isn't a problem with the ExpressionEngine .htaccess it's the other .htaccess for the calculator application that's causing the issue.

Change this line:

RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

to

RewriteRule ^(.*)\?*$ /calculator/index.php/$1 [L,QSA]

The original isn't rewriting within the calculator folder, it's re-writing back to the web root, which contains the EE install.

| improve this answer | |
  • Hi Peter, thanks for helping out! When I tried your example with RewriteCond %{REQUEST_URI} !(calculator) [L,NC] I got a 500 server error. And yes, I am actually trying to access a file within the "calculator" folder - /calculator/mortgage - specifically. – ByteMyPixel Jun 24 '13 at 19:54
  • Better than a 404! :) Try: RewriteCond %{REQUEST_URI} !(calculator) [NC] without the additional L, then if that doesn't work, try: RewriteCond $1 !(calculator) [NC] – Peter Lewis Jun 24 '13 at 20:04
  • True! I tried both of these rewrites and both returned 404's :/ I also tried with taking everything else out of my htaccess except for the rules for removing index php and trying with the different rules you posted for ignoring the directory = same results. – ByteMyPixel Jun 24 '13 at 22:31
  • Stupid question: Can you remove (or rename) the .htaccess file completely and access the /calculator/mortgage file? Also, how come there's no extension to the file? Is there an .htaccess inside calculator folder? – Peter Lewis Jun 25 '13 at 12:16
  • I renamed the .htaccess file in the root, and I do still get a 404 when trying to access /calculator/mortgage - this is pointing to the directory for a custom application built on the yii framework. I will post the contents of the /calculator directory's .htaccess file in an edit to my original post. – ByteMyPixel Jun 25 '13 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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