# EE 404 page for missing pages
ErrorDocument 404 /index.php?/global/404
The code above will only apply to non-ee 404 pages. Everything else will be run through EE which means if EE cannot find the page than it will send it’s own 404 headers and redirect.
As far as Apache is concerned if the url is rewritten and finds the EE index.php than the page has been found.
The next step is for EE to try and find a record. If all is setup right in EE and EE cannot find a page it will serve it’s own 404 page and correct headers.
To anyone have the improper headers on 404 pages, upgrading to 1.6.5 and turning on strict urls fixed it for me.
Using the current htaccess posted on Leevi’s site. (except I removed {ee:pages}|)
I moved the pages tag to a new line…not sure if it will actually work when I get some actual pages but…
RewriteCond %{REQUEST_URI} ^/({ee:template_groups}|members|P[0-9]{2,8}) [NC]
RewriteCond %{REQUEST_URI} ^/({ee:pages}) [NC]
On another note, my ‘remove www from url’ doesn’t work. Any ideas?
OK, honestly, what am I missing here?
1) I have 1.6.5 installed, with strict URLs enabled. 2) Using .htaccess generator, with ‘{ee:pages}|’ removed. 3) Specified an error template in EE. 3) Created a Template Group called “features”. 4) Visit www.site.com/features/ and I get a status 200 OK. 5) Visit www.site.com/featureszzz/ (doesn’t exist) and I get the error template with a status 200 OK.
Then I just disabled htaccess generator - and I get the same 200 OK response (and the EE designated error page shown) when I type a bunch of garbage in the first segment. This may not be an htaccess Generator issue.
Hey Everyone,
Regarding the 404 page error check out… http://ellislab.com/forums/viewthread/96894/ It might help with your issue.
Also make sure you have a 404 template set in your Global Template Preferences.
Found a small “bug” on a site we’re launching soon: If you click the “My Site” link in the top hand corner of the CP, the query string redirection does not seem to work:http://www.example.com/?URL=http://www.example.com/index.phpAnybody else experiencing this?
I’ll look into this when I get a chance. :D
OK, honestly, what am I missing here? 1) I have 1.6.5 installed, with strict URLs enabled. 2) Using .htaccess generator, with ‘{ee:pages}|’ removed. 3) Specified an error template in EE. 3) Created a Template Group called “features”. 4) Visit www.site.com/features/ and I get a status 200 OK. 5) Visit www.site.com/featureszzz/ (doesn’t exist) and I get the error template with a status 200 OK. Then I just disabled htaccess generator - and I get the same 200 OK response (and the EE designated error page shown) when I type a bunch of garbage in the first segment. This may not be an htaccess Generator issue.
Hey Ryan,
Your url in step 5 should not be parsed by EE at all if the template group doesn’t exist in the include rule. In that case Apache should serve it’s own 404 page up based on this rule:
# EE 404 page for missing pages
ErrorDocument 404 /index.php?/global/404
What happens if you change the rule above to something like:
# EE 404 page for missing pages
ErrorDocument 404 /404.htm
and create a static 404.htm in the root? That should be the page that is displayed for non-ee 404s.
EE 404’s should only be rendered when:
Example:
{exp:weblog:entries
require_entry="yes"
limit="1"
weblog="blog"
}
// redirect if no entry can be found to EE 404 page
{if no_results}{redirect="404"}{/if}
// else output the title
{title}
{/exp:weblog:entries}
I had some trouble with your example rewrite code for removing ‘www’ and also the removal of index.php, so this is what I ended up using: The example you gave just didn’t work so I had to use the one below.
# remove the www
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
Note that I took out a pipe (‘|’) after ‘{ee:pages}’ because it was doubling up.
# Remove index.php
# Uses the "include method"
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/({ee:template_groups}|{ee:pages}members|P[0-9]{2,8}) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
I’m having some trouble with the generated .htaccess file created.
The original file produced caused an internal server 500 error. So having read through this thread worked my way through the code until i found the section that was causing the error.
With this part removed from the .htaccess file, the extension appears to work (it removes index.php from the URL).
# secure .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Dont list files in index pages
IndexIgnore *
However after getting this to work i continued developing the site and found that when i created a new template group, the internal server 500 error surfaced its ugly head again. Having checked on the .htaccess file it appears as though full code (generated when “submit and generate” is clicked) is appended to the end of the code already present in the file. I also noticed that the new template groups are not included in the #remove index.php section.
Any ideas?
Does this extension update .htaccess when template groups or names are changed or deleted? I guess what I mean is can this be installed at any point in the website development? Will it keep the .htaccess current as template groups and templates get renamed, changed added to and deleted? Thank you and have a GREAT day!
Hi Guys
I’ve done a search on this and found nothing, so forgive me if this is answered elsewhere 😊
Using the LG.htaccess Generator 1.0 and got an issue with mailing list sign ups. The email received by the new subscriber includes the auto-generated link:
http://www.mydomain.com/?ACT=4&id=ENY5aj4MXI
When I remove the .htaccess file, the link works fine. Leaving it in defaults to the homepage, with no system confirmation of signup.
The .htaccess file reads as follows:
# secure .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Dont list files in index pages
IndexIgnore *
# EE 404 page for missing pages
ErrorDocument 404 /index.php?/{ee:404}
# Simple 404 for missing files
<FilesMatch "(\.jpe?g|gif|png|bmp)$">
ErrorDocument 404 "File Not Found"
</FilesMatch>
RewriteEngine On
RewriteBase /
# remove the www
RewriteCond %{HTTP_HOST} ^(www\.$) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Add a trailing slash to paths without an extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# Remove index.php
# Uses the "include method"
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/({ee:template_groups}|{ee:pages}|members|P[0-9]{2,8}) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Remove IE image toolbar
<FilesMatch "\.(html|htm|php)$">
Header set imagetoolbar "no"
</FilesMatch>
Can this be written differently to allow the sign up link to work? I don’t know much about writing rules and I’ve managed to get everything else to work on the site, but this would be a dealbreaker.
Thanks.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.