I would first try getting the basics to work:
RewriteEngine On
# 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} ^/(global|search|about|contact|careers|home|news|campus|members|P[0-9]{2,8}) [NC]
RewriteRule ^(.*)$ /index.php?$1
If that works then you can start to introduce the other rules until you find the problem.
I would first try getting the basics to work:If that works then you can start to introduce the other rules until you find the problem.RewriteEngine On # 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} ^/(global|search|about|contact|careers|home|news|campus|members|P[0-9]{2,8}) [NC] RewriteRule ^(.*)$ /index.php?$1
That “works”, but my returned headers are wrong. EE 404 pages return HTTP/1.x 200 OK. If I add the extra pipe, I get proper 404s again, but can’t access my system directory without adding index.php
I have also found that I have to add the double pipe in order to return a proper 404. Without the double pipe, my returned headers on non-existing pages return a 200 OK, although they are directing to the correct EE 404 template.
I don’t seem to have any trouble accessing the control panel when I have the double-pipe, though. Here is my .htaccess code (with additional code of my own…)
AddHandler php-script .html .htm
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.dykeman\.net$ [NC]
RewriteRule ^(.*)$ http://www.dykeman.net/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
#RewriteRule ^(.*) index.html
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
# 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>
# 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>
</IfModule>
Redirect /architecture/client_access/client_access.htm http://www.dykeman.net/client_access/client_access.htm
Any explanation as to why the double pipe is needed to return a proper 404 header?
Leevi, Thanks for yet another great extension.
I have run into a problem I have not seen documented yet. When using URL variables (http://www.domain.com/events/?sort=title) they are being ignored. The pages render fine (without the sorting of course), and this had worked before with just the include method. I’m thinking it must be something else in this extension that is making this happen. I wonder if you could point me towards what might be causing these variables to be ignored so I can hopefully fix this (and better understand .htaccess rules)
I understand that there are ways around using URL variables but the client has specifically requested that this be the way we handle this so there is no way around it.
I love all the nice benefits to the LG .htaccess Generator so I was hoping that I could continue to use this with the URL varibles.
Thanks!
UPDATE:
By changing this line:
RewriteRule ^(.*)$ /index.php?/$1 [L]
to:
RewriteRule ^(.*)$ /index.php/$1 [L]
it solved the problem. I am not sure if this will cause any other issues. Hoping Leevi or someone else can help.=
There is a little bit written at the bottom of this “remove index.php” Wiki article on the reason that question mark may be there.
There are host site ‘fixups’ going on (this one in early May 2008) where Apache or PHP config changes remove server variables that EE would like to depend upon. The latest has removed PATH_INFO completely, […]
I wonder if somehow you were essentially getting two question marks in the URL (one unseen) that was ‘breaking’ things.
I’m curious if things would work if you added the question mark back into the .htaccess file and wrote your link like this: http://www.domain.com/events/sort=title But if the client absolutely, positively needs to have the Q mark in there, I’d remove it from the .htaccess like you’ve done, as long as their server doesn’t need it there for things to work.
I’m curious if things would work if you added the question mark back into the .htaccess file and wrote your link like this: http://www.domain.com/events/sort=title
This made good sense to me (i was even excited because that URL looks even nicer w/o the Qmark) but failed when I tried it.
Hmmm… A great idea none the less.
That “works”, but my returned headers are wrong. EE 404 pages return HTTP/1.x 200 OK. If I add the extra pipe, I get proper 404s again, but can’t access my system directory without adding index.php
I just tried this myself and can confirm I get the same thing. I’m not using the pages module so I initially removed the {ee:pages} variable and the extra pipe. Not doing anything else out of the ordinary.
With no pages/2nd pipe: * Masked control panel access works without adding ‘index.php’ * Error pages appear to work correctly, but have ‘200 OK’ headers.
Putting the {ee:pages} variable and the pipe back in: * results in double-pipe (because I have no pages) * can’t access the control panel (masked or otherwise) without adding ‘index.php’ to URL * error pages are sent with proper 404
I’m curious if things would work if you added the question mark back into the .htaccess file and wrote your link like this: http://www.domain.com/events/sort=titleThis made good sense to me (i was even excited because that URL looks even nicer w/o the Qmark) but failed when I tried it. Hmmm… A great idea none the less.
You’d have to add the Q mark back to the htaccess file first (and regenerate the file), then remove the Qmark from your URL. You did both parts?
You’d have to add the Q mark back to the htaccess file first (and regenerate the file), then remove the Qmark from your URL. You did both parts?I’m curious if things would work if you added the question mark back into the .htaccess file and wrote your link like this: http://www.domain.com/events/sort=titleThis made good sense to me (i was even excited because that URL looks even nicer w/o the Qmark) but failed when I tried it. Hmmm… A great idea none the less.
Yes I had done both. Initially it tried to read “sort=title” as a segment and kicked me out to http://www.domain.com/events/sort=title/ which was not a valid page.
I have tried a number of logical combinations including removing the following:
# 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]
No need to get into the other assorted things I’ve tried. I suppose the point is that I’m not really 100% solid on these rules so I’m kinda doing a trial and error process.
Wow what a great plugin!
The documentation states that anytime a new weblog entry is created a new .htaccess file is generated with rewrites for the new page URLs. However, I tried creating a few static pages as new entries and set the URLs accordingly but did not see the page URLs entered into the .htaccess file.
Any thoughts?
OK, I’m just trying to activate the extension and getting this error.
Not Acceptable An appropriate representation of the requested resource /ski-physio/”mySystemFolderName”/index.php could not be found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I’ve never tried to get rid of the index.phpp before but my client has requested it.
Can anyone help. I have to admit 90 % of the stuff in this thread is going over my head.
So from my tests, its not actually the extra pipe thing thats the problem, its:
# EE 404 page for missing pages
ErrorDocument 404 /index.php?/global/404
If I comment that out, I get proper headers. But I don’t get an ee 404 at the root (site.com/notatemplategroup). Haven’t tried with 1.6.5 strict urls though.
Leevi, is there a reason the ErrorDocument line is written the way it is, initially (with the question mark)? Also, why does this line need to be specified? If I’ve specified a 404 page in EE, won’t that automatically get called when there is a bad 1st segment?
Because we are using the include method only included ee templates will fire a 404 if you have a bad second segment.
The initial 404 line is to catch any traditional 404 pages and redirect them to the EE 404 page purely for styling. The “?” is added because you want EE to render it as a normal page but apache will send the 404 headers. Also the visitor will never see the /index.php?/global/404 path just the rendered page content (just like a regular 404).
Confusing …. yes :D
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.