We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

LG .htaccess Generator

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

I wonder if the error headers will be correct if EE 1.6.5’s “Strict URLs” is enabled? Strict URLs would seem to take care of segments 1 and 2.

Agreed - confusing…yes.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
16 years ago
Leevi Graham's avatar Leevi Graham
# 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.

       
timkelty's avatar
timkelty
177 posts
16 years ago
timkelty's avatar timkelty

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}|)

       
4flix's avatar
4flix
88 posts
16 years ago
4flix's avatar 4flix

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?

       
gridonic's avatar
gridonic
231 posts
16 years ago
gridonic's avatar gridonic

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.php

Anybody else experiencing this?

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

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.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
16 years ago
Leevi Graham's avatar Leevi Graham

Hey Everyone,

Regarding the 404 page error check out… http://ellislab.com/forums/viewthread/96894/ It might help with your issue.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
16 years ago
Leevi Graham's avatar Leevi Graham

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.php
Anybody else experiencing this?

I’ll look into this when I get a chance. :D

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
16 years ago
Leevi Graham's avatar Leevi Graham
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:

  • you have a matched template group / template
  • the entry requested cannot be found
  • the require_entry=”” param is set to yes
  • and the template includes the {if no_results}{redirect="404"}{/if} redirect.

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}
       
Leevi Graham's avatar
Leevi Graham
1,143 posts
16 years ago
Leevi Graham's avatar Leevi Graham
Then I just disabled htaccess generator

One other thing… disabling the generator will not change anything. You’ll also need to delete the .htaccess file to see any affects.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

For reference, see also this thread.

ETA: Nevermind me double posting.

       
MeanStudios's avatar
MeanStudios
335 posts
16 years ago
MeanStudios's avatar MeanStudios

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]
       
Boxhead's avatar
Boxhead
13 posts
16 years ago
Boxhead's avatar Boxhead

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?

       
Capt.Mike's avatar
Capt.Mike
69 posts
16 years ago
Capt.Mike's avatar Capt.Mike

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!

       
PositionOne's avatar
PositionOne
57 posts
16 years ago
PositionOne's avatar PositionOne

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.

       
First 5 6 7 8 9 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.