cancel
Showing results for 
Search instead for 
Did you mean: 

Controller showing 404 error

Controller showing 404 error

The below given code is my controller code placed in app/code/local/Kart/Slider/controllers/IndexController.php

 

<?php 

class Kart_Slider_IndexController extends Mage_Core_Controller_Front_Action

	public function indexAction(){
	    $this->loadLayout();
    	    $this->renderLayout();
	}

}
?>

This is the config.xml placed in app/code/local/Kart/Slider/etc/config.xml

<?xml version="1.0"?>
<config>
	<modules>
		<Kart_Slider>
		<version>1.0.0</version>
		</Kart_Slider>
	</modules>
	<frontend>
		<routers>
			<kart_slider>
				<use>standard</use>
				<args>
				<module>Kart_Slider</module>
				<frontName>slider</frontName>
				</args>
			</kart_slider>
		</routers>
	</frontend>
</config>

I am gettin a 404 error when I use localhost/magento/slider/index. I am using a linux box. I am a beginner in magento. Am I missing anything in the code? Help is appreciated.

My problem is, I want to use jquery.post() method to get the product details of a given product based on product_id, in another div or modal when i click on a product. But am not able to make a controller which will take id as a parameter and return the details of the product in json. If another possible way of doing it is there then please help me. If anyone knows a complete tutorial to acheive this, or anyone can help me, I would be grateful. I am stuck on this from the last 2 days and am a self learner. I have done a lot of googling but I did not find an appropriate solution or reason of what is going wrong.

 

Thanks for your help.   

5 REPLIES 5

Re: Controller showing 404 error

Hi @gandhar

 

Did you create a register file for you module in app/etc/modules ?

 

It should look something like this:

 

<?xml version="1.0"?>
<config>
	<modules>
		<Kart_Slider>
		    <active>true</active>
		    <codePool>local</codePool>
		</Kart_Slider>
	</modules>
</config>

 

Re: Controller showing 404 error

yes. and the module is showing enabled.

Re: Controller showing 404 error

Hi @gandhar

 

I tried pasting all the code into a clean Magento install, worked right away execept for the fact that you forgot a { after your class opening, but i'm gusing that just from pasting the code in here.

 

If you have cleared your Magento installs cache then you should be good.

 

Also on a small extra note, there is never a reason to close PHP in class files. This can only cause problems like acidently adding whitespace to the end of the document, which will prevent headers form working correctly.

Re: Controller showing 404 error

It could be because of the below reasons

 

i) .htaccess file or nginx rule doesn't have the rewrite rule to remove index.php

           you can test whether you are able to hit the controller via localhost/magento/inde.php/slider/index.

 

ii) If that didn't work the check "append store view code in the url" under System--> Configuration --> Web --> Add Store Code to URLs

    Set --> No --> Save Config --> Cache Clear.

Re: Controller showing 404 error

@gandhar

 

Try to call the controller action like localhost/magento/slider/index/index
After that, disable your magento cache and do re-indexing.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now