Hot answers tagged

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

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

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'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 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

The only thing you normally need for 404 with a require_entry="yes" and strict urls enabled is: {if no_results}{redirect="404"}{/if} Can you just try this on a clean template? As others have said, a broader context could help debugging this. EDIT: if, as per your comment, you know you should only have two segments, then simply modify the code as follow to ...


2

Rather than do it via htaccess why not use EE segment tags. {if segment_1 != "en"}{if segment_1 != "fr"}{redirect="/en/"}{/if}{/if} I've nested so that it's an early parsed simple conditional. Otherwise you'll be getting into the realm of settings cookies and reading them in the htaccess.


2

Try setting the 404 status using HTTP Header plugin. Put following tag in your 404 template: {exp:http_header status="404"}


2

Unfortunately there wont really be an easier way than with Freebie. It's designed for this very purpose when you need EE to ignore certain URL segments and comes in very handy when dealing with Structure because of the way it deviates from EE's native URL handling. In the case of both strict URL handling and Structure you definitely need to break those URL ...


2

Robson's suggestion is on the money. Another approach would be to use the awesome IfElse add-on so parsing is less of an issue. Using your example, it would look something like this: {exp:ifelse parse="inward"} {if segment_4 != "" || segment_2 != "staff-bio"} {redirect="404"} {if:elseif segment_2 == "staff_bio"} {if segment_4 == ...


2

Adding an additional segment on to the end of a Pages URI will trigger a 404. I recommend using the Freebie extension to set an ignored segment, in your case "thank-you." This will allow you to redirect to /contact/thank-you and show the contact page while still using the second segment for any conditionals. {if freebie_2 == "thank-you"} <p>Your ...


2

For SEO purposes, I don't think it's a good idea to return a 301 redirect when you want to return a 404 error. When you do {redirect="404"} then EE serves the 404 template with a proper HTTP 404 status response. When you do {redirect="404/index"} then EE responds with a HTTP 301 status redirect header. Google Analytics and Webmaster Tools track when a URL ...


2

http://mysite.com/about/non-existent will load the http://mysite.com/about template. This is because EE looks at that second segment automatically for a number of things... if there isn't a template name there it will try to load an entry with that url_title into the /about template. To stop this behavior, add this into the /about template: {if segment_2 ...


2

Check your htaccess file. It's possible you have a 404 redirect statement there too which should be removed.


2

Ha ha, found it! Removing index.php code in the .htaccess file also needed updating. Original RewriteRule to remove index.php: RewriteRule ^(.*)$ /index.php?/$1 [L] New RewriteRule needs the sub-folder added to the RewriteRule: RewriteRule ^(.*)$ /subfolder/index.php?/$1 [L] Note: the question mark after index.php depends on a server setting, so ...


2

The problem is that the redirectee plugin use the native PHP header function which not support the 404 code. In fact it is a little bit strange to send a 404 with the header. Therefor you have to use a 302 code, the 404 page will send a 404 code on his page. As for redirecting with the 404 code, you have the think of this QA: User: Hey, do you have ...


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