Hi I created a codeigniter project but when I click on a link to one of my functions, example add user, I get redirected to the main page of my local host XAMPP installation instead of being taken to the correct application url. What can be the problem? Thanks
Have you set the base URL in the CI configuration? file projectname/application/config/config.php? This might be the problem... I guess your project isn't on the webroot, but your base URL is missing the /projectname/ part.
$config['base_url'] = 'http://example.com/projectname/';
How do you create the link (can you show us the code)? If you are not using the URLHelper take a look at urlHelper.
I am just guessing, but maybe you are missing the Controller name (you have to load the UrlHelper), e.g.:
Link to the controllers method
or (see Jordan Arsenault's comment below on the usage of the site_url call for better performance):
<?= anchor('/name_of_the_controller/method_to_invoke', 'Link to the controllers method'); ?>
I hope this helps.
Related
I have a problem regarding paging of the custom module. When i click on the next page the it take the url as localhost/magento/fme-support/index/index/url/BC/?p=1, but this url doesn't work properly, the correct URL is localhost/magento/fme-support/category/BC/?p=1.
Please suggest me how and i change this url.
Thanks.
Try making url rewrites off
If it doesn't work there is some issue with your extension you have installed
Check for redirect in your extension
The "index" in the URL means you are calling the index controller of the module.
Magento module URLs work like this
http://magento_installation.com/(storeview)/moduleMame/controllerName/functionName/
I developed a site in codeigniter with basic functionality now i want to update this site to my live server. But when i uploaded my site to live server it shows 404 - PAGE NOT FOUND.
http://www.nawtist.com/test/ams/
Please tell me what do i need to do. I searched a lot about this but i didn't found any helpful information. So is there any base_url or anything else that i need to change before upload this on live server really appreciate
And remember, many servers are case-sensitive and with CodeIgniter v3 you should change the controller's first letter file and model's first letter file to upper case. That worked for me too.
Best
You have problem with your htaccess file or mod_rewrite is disable on that server.
When you go to page with index.php it works (although css file doesn't work because of bad routing)
also check if $config['index_page']=''; if it should work without index.php
I had the same problem times ago and there are 4 points in codeigniter to care about as I remember:
Check base_url value in your "config.php"
Check database settings in "database.php"
Check .htaccess file contents if you have defined it once
Check routes.php if you have defined any custom routes
That's all!
If you are facing 404 page not found in Codeigniter after upload file local to live server then follow these steps
change your controller and file name first letter capital
same change as above in model class and file name i.e first letter capital
After following steps above your problem can be solve Thank you.
After searching a lot around, I decided to post this matter here.
I am working with codeigniter ( latest release). I need to have the URLs of my site working like below.
[username] / [controller] / [action] / [parameters]
as you can see the username is leading on the URL rest follows as normal. I need to fetch the username and get some data for the site so that that site could be customized according to his settings.
I tried to achieve this with .htaccess but had no luck. Then I checked with routing on code igniter, but I am not sure whether it's the right solid solution for me. can someone give me any leading on this. is this possible ?
Thanks
I would advise to use the routing option from Codeigniter.
http://codeigniter.com/user_guide/general/routing.html
$route['(:any)/user/viewprofile/(:num)'] = controllername/functionname/$2";
This way you can build classes and functions in an nicely ordered way.And keep it in codeigniter.
$route['(:any)/controller'] = 'controller/users/$1';
This will pass the dynamic username to the controller
I am using CodeIgniter to design a website, and I am having trouble getting anchor to work correctly.
Here is how I am using it. It is used in a file in views folder of application in codeigniter.
<?php echo anchor('/profile', 'PROFILE'); ?>
My intention is to have anchor load the profile controller, which is in the controllers of application in codeigniter. However, when I clink on the link, it says that the the file is not found.
I autoload the url helper functions alreader, and other functions from that file are working, like site_url() .
I don't know what I could have missed? Do you ave any suggestions? This is my second project with codeigniter, so I am still learning.
EDIT: Yes, I am following the naming convention in codeigniter, and the file has an index function. I tried without the forward slash and it still gives the same result.
The HTML link that this produces is localhost/profile. This is what I Should get right? Since for codeigniter, it's url/controller/function. I did a mod rewrite to remove index.php from the url, but that shouldn't be a problem, should it? I'll try and check the base url again.
Are you sure you need the leading forward slash?
Have you tried:
<?php echo anchor('profile', 'PROFILE'); ?>
You would only be using the slash if you are trying to get into the "profile" sub folder inside your controllers folder.
What helps me when urls get confusing is to type into the browser the full url to the path I want to get to (to make sure I'm not getting a 404, etc). From there you can start from the end and go back to see what you are missing.
But you generally want to start with a controller name and add the function you are calling like:
anchor(controllerName/functionName)
See CodeIgniter URL Helper for examples.
EDIT: also - you may need to check what your config base_url is set to. if there's fancy .htaccess stuff happening, your base_url needs to be set properly.
There is a very simple solution go to config/constants and define SITE_URL there and set its value to
http://localhost/myprojectname/index.php.
Then use it here like this.
<?php echo anchor(SITE_URL.'/profile', 'PROFILE'); ?>
How to code or achieve this url like wordpress
for example
http://www.example.com/product/view/my-product-sample
is there way to have this url ? any tips tutorial example thank you guys :)
Well, this is already a valid URL without any alteration, calling the controller product, method view with the argument my-product-sample.
However, I think you are looking for routing.
Example:
$route['product/view/(:any)'] = 'products/view_product/$1';
This route is saying: If user requests
product/view/(something)
give them
products/view_product/(something)
As usual, see the user guide for more information.