5

Weird one - haven't seen this before. Just launched a newly upgraded from ee1 to ee2 site at www.bankofmarin.com. Everything works fine. This is a Structure site and I have strict URLs on to enforce 404 with bad URLs. Works fine.

We need to place some non-ee php files in the root, and they just aren't working. This one https://www.bankofmarin.com/t.php should show the date. Instead I get the 404 page.

Here is my htaccess:

# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /

# Use Dynamic robots.txt file
# ------------------------------
RewriteRule robots\.txt /robots.php [L]


# Force the www - this version will not force www on subdomains, only http://bankofmarin.com
# ------------------------------
RewriteCond %{HTTP_HOST} ^bankofmarin.com [NC] 
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]


# Force https - this will only force https on the www site
# ------------------------------
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^dev\.
RewriteCond %{HTTP_HOST} !^staging\.
RewriteRule ^(.*)$ https://www.bankofmarin.com/$1 [R=301,L]


# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/admin/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]


# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

I thought it might be something in there but its all pretty straightforward. Any ideas?

  • Was this solved for you? or do you still need assistance? – nonprofit_tech Dec 6 '12 at 20:06
  • Nope still can't make it work. Haven't had time to look at it again in a few days though. – Chad Crowell Dec 12 '12 at 4:47
9

I'm not an .htaccess guru, but we worked with someone to develop a base .htaccess file for use with our clients, and they all contain this

## MOD REWRITE BASE
## Checks for file/folder before serving pages in ExpressionEngine
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png|txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
#RewriteRule ^(.*)$ http://www.domain.org/$1 [R]
## END MOD REWRITE

The goal was to always have EE check to see if there was a file that existed first, then process ExpressionEngine requests and it's been working for us. We just modify the {domain} component for each client.

If I recall, the consultant who helped us with this said that

RewriteCond %{REQUEST_FILENAME} !-f

checks for the file name first, then

RewriteCond %{REQUEST_FILENAME} !-d

checks for a directory with said, file, then

RewriteRule ^(.*)$ /index.php/$1 [L]

removes the index.php. The remainder is the domain magic.

We've been using that as a base for .htaccess file for over 6-8 years now, it it hasn't failed us.

  • 1
    Excellent response. The !-f should get Chad squared away. – Erik Reagan Dec 4 '12 at 13:36
  • 1
    That code is already in my htaccess. – Chad Crowell Dec 4 '12 at 19:11
  • 1
    Sorry, didn't realize I could scroll down. This could be an order issue. Did you try moving the EE piece before the index.php Redirects? What you can do is comment out the full # Redirect index.php Requests section, then check to see if the file loads. If so, then move the Standard EE ReWrites up higher and remove the comments. If it stops working again, then you probably have a conflict between the purpose of the two statements. – nonprofit_tech Dec 4 '12 at 20:43

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.