Hot answers tagged

18

There are several strategies for best utilizing 404s on a Structure site: Hide Structure Templates to Prevent Duplicate URLs First, make sure that any Structure-assigned templates are either hidden, or inside a hidden template group (prepend the group or template name with "_" or "." - so "_blog" or ".blog"). This ensures that there is no duplicate EE URL ...


12

There are 3 things that should fix this. Assign your 404 error template in your "Global Template Preferences" which can be found at Design > Templates > Template Preferences In your products template, add the require_entry="yes" parameter to your channel:entries tag Inside that channel:entries tag add the following to redirect incorrect requests to the 404: ...


9

Your biggest point of attention should be the response header for your URL. EE will take care of setting it as a 404 response provided you have selected the template in use in the Global Template Preferences seen below. (Docs reference) I'd recommend using a template rather than an entry + pages module. It's just simpler that way.


6

Following on from Eriks post, I've created a global variable for detecting whether the page is a pagination page, and it's set in my master config: $vars['global:is_pagination'] = (preg_match('/P[0-9]+/', $_SERVER['REQUEST_URI'] )) ? TRUE : FALSE; and then in my news/index {if segment_2 != '' && segment_2 != 'category' && global:...


6

Because EE (and CI) run all page requests from a single index.php they must pull in the dynamic data from the URL. In general it does this via the server environment variable PATH_INFO. The problem, though, is that not all servers have this environment variable set. That's why EE and CI allow you to change how the URI is read. In some cases the environment ...


6

I've never used EE before version 2 so not 100% sure this will work, but hopefully it helps. Inside your weblog entries tag (I am assuming it is a weblog entries tag, if it is not, post what it is here) put the following code: {if no_results} {redirect="404"} {/if} This also assumes you have a 404 page set up in your configuration. This may not work, ...


5

This will depend entirely on how you have your server set up. ExpressionEngine is only aware of things that go through the index.php file (or if you have by chance renamed this file, then whatever you renamed it). On Linux servers, often .htaccess will be used to remove index.php from the URL but still send all requests through index.php. So for instance, ...


5

You can't delete index templates, so you'll have to include {redirect='404'} on those templates to force them to 404.


5

If you are running from localhost:8888, then locally you are essentially running these sites from subdirectories. So the .htaccess you are using (RewriteRule ^(.*)$ /index.php/$1 [L]) is sending requests to http://localhost:8888/index.php. Try the second exception from the user guide: RewriteRule ^(.*)$ index.php/$1 [L] Notice there is no / in front of ...


5

This is a known bug in EE 2.9.0: https://support.ellislab.com/bugs/detail/20471/site-index-template-is-rendered-after-the-404-template The fix from that thread: Open system/expressionengine/libraries/Template.php and find this code on line 2236: ee()->output->out_type = "404"; ee()->output->set_output($out); ee()->output->_display(); ...


4

Since you are hard-coding an entry_id in your channel:entries tag in your products/index template, and as long you don't need any additional url segments to trigger other behavior (such as pagination or for dynamically loading another entry), you could just do this: {exp:channel:entries channel="products" entry_id="12"} {if segment_2 != ""} {...


4

You might read this article Guide to 404 Pages with ExpressionEngine It would help you great.


4

This looks like a bug on the no_results conditional, to me. May I suggest you something? Let's change your approach to this. Look at the docs. You should take advantage of the parsing order and do not let your code run if you can avoid. So, use simple conditionals around the channel:entries variable pair. This way, in the two first situations, the parsing ...


4

When using the Pages module, the URL Title is not used and should not be fed to to the {exp:channel:entries} tag. If you remove that parameter from the tag and change dynamic="yes" or remove the dynamic parameter altogether, it will pick up the correct page entry automatically. You'll also need to make sure the entry with the Page URI set has the correct ...


4

If you are using EE 2.7+ there is a new current_query_string global variable you can test against. {if current_query_string} {redirect="404"} {/if} Or, for versions less than EE 2.7... Install the Mo Variables Extension and enable the setting that gives you a {query_string} variable. Then in your homepage template you can do {if query_string} {...


4

You need to use the require_entry parameter: {exp:channel:entries limit="1" require_entry="yes" [...]} {if no_results} {redirect="404"} {/if} [...] {/exp:channel:entries} This parameter make the {if no_results} conditional available.


3

You'll need {if switchee_no_results}{redirect="404"}{/if} if nested inside switchee, due to switchee's parse="inward"


3

Is this URL failing? EE shouldn't do anything. Since the directory exists on the server it should load just fine. There will only be an issue if you have a template group with the same name. In that case, EE will load the template group if I remember correctly.


3

You might find Guide to 404 Pages with ExpressionEngine useful: http://joviawebstudio.com/index_ee.php/blog/guide_to_404_pages_with_expressionengine/


3

You don't need to use the Pages module, but you can use a channel entry to make the 404 page more dynamic, it just needs a dedicated template in order for the ExpressionEngine 404 handling to work correctly. Often I'll simply duplicate my standard page template to be my 404 template and just hard code the entry in, instead of dynamically loading it from the ...


3

Mel touched on part of our approach. We use the require_entry parameter in most channel:entries loops. That's part of the process. Next, we imploy multiple conditionals to check for URL hackers errors. General URL Structure We like pretty and concise URLs so our blog/index EE template looks like this in its entirety: {!-- /** * blog/index is a master ...


3

Take the standard method and add in your subfolder name before index.php in the RewriteRule. <IfModule mod_rewrite.c> RewriteEngine On RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /SUBFOLDER/index.php/$1 [L] </IfModule>


3

It looks like your 404'd page works with index.php: http://warpedcoders.com/charlie/index.php/news/page_content So, try this for your .htaccess rewrite: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On ## Removes index.php RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...


3

You can accomplish that by doing the following: Make a template group called 404.group and in that template group create an index.html template (this will be your 404 template) Set "Enable Strict URLs" to "Yes" in your Global Template Preferences For the "404 Page" setting choose "404/index" (the template you created in step 1 above), again in your Global ...


3

You are missing the opening { on the href's tag, and {title_permalink} has an underscore _ not a dash. <li><a href="{title_permalink="site/essay"}">{title}</a></li> See EE Docs on Permalinks


3

I don't think the issue is with the friendly URL's, however you can test this by removing that block from the htaccess and typing the index.php part into your URL : http://www.example.com/index.php?foo=bar Another thing to check is that ExpressionEngine itself is not clearing the get parameters, which can happen as all ee actions are submitted to the home ...


3

Check and make sure your /index.php is in place and configured correctly.


3

Finally resolved this. On a whim I decided to try the URL /en and that had the same effect too so that meant it had to be language related, with the original problem being with 'de'. In my htaccess, which is where I started in the first place, I found a reference to a multi-lingual snippet, which included en|fr|es and wouldn't you know it....de. Removing ...


2

what about using require_entry="yes" http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#require-entry Then {if no_results}{redirect="404"}{/if}


Only top voted, non community-wiki answers of a minimum length are eligible