In codeigniter routes file there is a setting called
$route['404_override'] = 'general/not_found';
So as you can see i have given a method there. The problem is this isnt working properly. From some pages the error 404 is showing the page that ive set in the method but for some pages it is showing the default codeigniter 404 page.
So i assume that this is a bug in the framework itself. Have anyone of you faced this before? If so what is the best bypass method available to get all 404 pages return custom page?
I answered to something similar on this SO question
Basically, that's not a bug because custom re-routed error messages don't affect the calling of the core function show_404(), but only the controller-generated error message.
In order to solve this you need to make a small hack to the core show_404() inside the Exception class, and its consequent call on the show_error() function in common.php. Alternatively, follow #Eric LaForce suggestion and modify/extend the Exception class in order to work on your new directives.
Without more detail on which pages show the 404 and which do not, I am not sure, but it sounds like this person has also run into a similar situation and has devised a solution. At the very least it may point you in the correct direction. Hope it helps.
Related
We are using Joomla for a public site and we are getting a ton of soft 404 errors that all look similar to
/?option=com_k2&view=itemlist&task=user&id=xxx
where xxx = some numeric id. Obviously this is some soft of spamming but how do I turn it off in Joomla/K2?
I'm not particularly Joomla oriented but this seems a task I should be able to accomplish if I can get an idea of "where" to fix the code. The page shows a warning instead of an error
Warning
JUser: :_load: Unable to load user with ID: 35414
so it seems the "page" is actually there but with no content. I'm guessing some internal handler is spitting this dynamic content out but I want to return 404 in this case. Any ideas would be appreciated.
I'm trying to understand the nature of your problem. What do you mean with "Soft 404" errors? Do you have 404 errors or not?
On my K2 websites, I have sometimes "visitors" who try to find holes in K2. I then have many, many accesses of the same page. These visitors try to post comments or somethings else on the articles or user profiles.
Is this a similar thing that is happening on your site?
Is there a (Joomla) user on your site with ID 35414? If not, you can be pretty sure that someone is trying to hack your site.
Is the URL always requested by the same user? You can find this in the log files of the Apache server. In such cases I add a "deny from" statement to my .htaccess file.
In case you seriously expect a K2 related issue, I would recommend to post the issue in the K2 forum. This forum is quite knowledgeable and JoomlaWorks makes a serious effort to bring good K2 customer support.
I have a simple question, what could cause this:
At magento success page there are no order number
Its just empty, what could cause this problem?
Order id are loaded by this line
$this->escapeHtml($this->getOrderId())
Code are loaded by manabee ordershare module.
Also this shop have many modules and code changes.
So I need as many as possible ways you can suggest why this is happening. I will check them all.
Meanbee_OrderShare_Block_Ordershare extends Mage_Checkout_Block_Onepage_Success so it should work as the standard success page block. The getOrderId metod comes from Mage_Checkout_Block_Onepage_Success. I recomend you check the exception.log, system.log and php error log, maybe you have an error. I allways recomend to read core files, then you will know how it works.
I think that you should check what you have in chechout session at first.
This is something I feel should be easy, but after an hour so far scouring the web it just does not seem to be jumping out.
What I want is to have a module trigger a task in a component, then redirect to the last page.
To do this I want to get the current route in the modules form. However I cannot find any Joomla function that can output the current pages "JRoute", if I try use JRoute with no parameters it just outputs the url with no query, so will every method of JURI.
There must be an obvious answer to this, however for some reason I might just not be searching for the right thing and not turning up any results.
Try:
JURI::getInstance()->toString()
This will give you the current url.
I know this question has been asked in a similar fashion several times. However, I'm struggling to find any answers that would work in my situation. I primarily work on Microsoft projects and stepped in on this project to help during crunch.
Here's the situation.
We have a client who has a site with over 600 different pages. In reality each page uses the same template just populates with different data. We've developed a CMS for him which allows him to create new pages at will.
My ideal solution would allow me to store the name of a newly created page in a DB.
Ex. new_page_1 has been created and now exists in the DB. Now when I type in www.mysite.com/new_page_1 this needs to go to a controller that looks up "new_page_1" (in DB) and if it exists loads a view (THIS VIEW WILL NEED TO BE USED FOR ALL 600 pages) which then takes other data from the DB and populates various sections.
So essentially, over 600+ pages need to use the same route array and map to the same controller which then maps to the same view.
I've tried using $route['(:any)'] = 'custom_controler/create/$1 and as well as the same array key but using main and _remap. No matter what every single time it tries to look for the page name in my views (which it will never exist because I'm using one generic view for 600 pages)
Any ideas on how to accomplish this?
UPDATE
routes.php (this is the last line in the file)
$route['(:any)'] = "main/create/$1";
main.php (controller)
class Main extends MY_Controller {
public function __construct() {
parent::__construct();
}
public function create($page)
{
$c = new Category();
$c->get_by_name(ucfirst($page));
$this->load->view('site/index',$c);
}
}
the URL I'm attempting is sitename.servername.com/health sitename and servername obviously substituted.
The error I get is
An Error Was Encountered
Unable to load the requested file: health/main/create.php
Is the error page you're seeing the CodeIgniter error template or a generic server error? That error string sounds very much like you are using Apache or Nginx (or whatever main webserver you use) and its actually not even resolving to your CodeIgniter app at all, but searching for a PHP file that doesn't exist. You'll probably need to use mod_rewrite or something like that to make that URL point at the CodeIgniter install.
Otherwise, your implementation doesn't look completely wrong: you probably need to make sure main.php is the default route as well.
Your application will only look for the page name in your views if you tell it to. Your catch-all controller method should be checking the database for a valid page name, and then regardless of which pages validate, loads the same view (albeit with different data passed to the view).
Using an (:any) catch-all route is perfectly fine. Your controller code somewhere is what's throwing you off. Update your post with the code if you continue to struggle.
I’m a recent user of Codeigniter and am developing a simple backend CMS to manage pages.
Based on a URL (in this example I have hidden “index.php”) : mysite.com/pagename
I would like the system to detect if there is a value of “pagename” in my database, if there is, I need the system to re-route to a custom controller (eg: Pagemaker) and if there is no record called pagename, just do it’s normal thing (i.e. find a controller called pagename)
Currently I have:
$route['(:any)'] = "pagemaker/create/$1";
whereby all requests are forwarded to my custom function.
However I want to change this structure so that if the page does NOT exist in the db, the traditional codeigniter request process is followed.
Can anyone offer any advice about how to complete this? Or any advice about routing custom CMS’s in codeigniter in general?
The best solution is to upgrade to CI 2.0 because it's stable enough and it gives you plenty of useful features.
In your case, set the following route:
$route['404_override'] = 'pagemaker';
If the router doesn't know where to go it just goes to pagemaker controller. This can then check if the first uri segment exists and if not you create a custom 404 page instead of the crappy default one.
And I don't want to hear any of this "Oh but it's not released yet" crap, I've been using it CI 2.0 for almost a year. ;-)
I can think of two possibilities:
1) Edit your custom function to let it redirect your client when page's not in the db
pseudo code:
if($dbresult == null){
redirect("http://yoursite.com/"+$this->uri->segment(3));
}
2) Edit the router class of CI so it will first check if the page's in the db and if not, just continues. This may be somewhat messier as you need a db connection in your Router.php