Hi,
I am trying to configure EE with LG (commercial) to do this:
Add a trailing slash when there isn’t. Example: example.com/mypage >>301 redirect >> example.com/mypage/
Generate a true 404 HTTP header response code on error pages. For now EE is returning a 200 response which is not ok at all.
Return a 404 code directly, without redirecting with a trailing slash like above, when the page just doesn’t exist. Example: example.com/anynonexistingpage should return a 404 directly.
I’m trying to fix this for a long time now and can’t make it work as it should.
Can somebody help there?
Thanks
I did install the LG .hataccess generator but it didn’t solve any of these issues. My .htaccess generator setting look like this:
# 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]
It did remove the index.php as it should but the trailing slash, 404 pages returning a 200 code, and trailing slashes added after non existing pages remain.
Not sure what to do at this point.
Hi, I am trying to configure EE with LG (commercial) to do this: 1. Add a trailing slash when there isn’t. Example: example.com/mypage >>301 redirect >> example.com/mypage/ 2. Generate a true 404 HTTP header response code on error pages. For now EE is returning a 200 response which is not ok at all. 3. Return a 404 code directly, without redirecting with a trailing slash like above, when the page just doesn’t exist. Example: example.com/anynonexistingpage should return a 404 directly. I’m trying to fix this for a long time now and can’t make it work as it should. Can somebody help there? Thanks
I’m not sure if this will solve all your request, but, I corrected the issue by adding the following php to the top of my 404 template page. Now it returns the proper http headers rather than the code 200 OK.
<?php
global $TMPL, $OUT;
$OUT->out_type = '404';
$TMPL->template_type = '404';
?>
Be sure to allow php in the template preferences for your 404 template.
Hope that helps.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.