How routing is done in codeigniter? - codeigniter-2

I could not find the .htaccess file in CodeIgniter framework and i'm wondering how do they do route without it? Or it is somewhere hidden?

There is no .htaccess by default provided with codeigniter. They serve it through the index.php. .htaccess is only used to direct the urls to the index.php. This way codeigniter is working in environments where rewriting isn't allowed. Another way of getting controller and function is by query strings.
Anyway the actual routing is done in system/core/Router.php so you can read the code. Since Codeigniter is open source application that can't be hidden.

Related

How to Redirect urls after index.php in Laravel

We have a classified website developed in Laravel Framework. After analyzing the url structure I am getting the following issue:
Original Url: https://in.mysite.com/female-clothes/mycity
Duplicate Url: https://in.mysite.com/index.php/female-clothes/mycity
Every url is being duplicated as per the example given above.
Please let me know how to fix the above issue.
I think best option would be to 301 redirect Duplicate url to the Original url.
Please let me know the htaccess rule to fix the issue.
Do you know which version of laravel?
From what you've said this could be happening in the server (htaccess) or the application (laravel).
Laravel is able to handle url manipulation and redirection. The routing logic is usually found on the file called web.php (router.php for older version). It seems that the string 'index.php' is being inserted in the middle of your urls so look for it there.
If it's not happening in Laravel it could be in the htaccess, so look there as well.

What is the maximum layer of subdirectory at codeigniter controllers

I have a a project(codeigniter) where file directory is like that.
mysite
application
config
controllers
super_admin
admin.php
tasks
setup
bank.php
assets.php
Now if I try to access
http://localhost/mysite/tasks/seutp/bank
It calls codeigniter 404 page
But I can access
http://localhost/mysite/tasks/assets
Actually I can get access any controller under controllers and controllers/tasks folder.
But I cannot get access under controllers/tasks/setup folder
My question is
Is there any limitation of sub-directory at codeigniter?
If Yes: Is there any way to solve the limitation and How?
If No: Why I cannot access the third layer sub-directory controllers?Did I do something wrong?
yes there is a default for the ci controllers file folder levels. i am using this solution:
https://degreesofzero.com/article/controllers-in-sub-sub-folders-in-codeigniter.html
the author includes a lengthy mod rewrite but if you already have a working htaccess rewrite file to eliminate index.php from the url then it will probably work as is.

joomla rename component url using htaccess

I'm building an eshop using Joomla 2.5 and a commercial component for a guy who wants to have multiple vendros and I'm stuck on how to change the component's url.
What I want to change is the url that is displayed when the users passes from a link with his mouse.
For instance, the component has a SEF function which rewrites urls and makes them like that:
http://www.site.com/componentname/products/productname-productid-productcategoryid-vendorid.html
http://www.site.com/componentname/catalog/categoryname-categoryid-numberofpage.html
and what I want is to make it:
http://www.site.com/shop/products/productname-productid-productcategoryid-vendorid.html
http://www.site.com/shop/catalog/categoryname-categoryid-numberofpage.html
So when a user passes over a link it will show him the new url. Is this possible with .htaccess and rewrite rules or this can only be done through the component only? I'm asking this as the component is encoded with ioncube so I can't do it myself.
Thanks in advance!
While you can use .htaccess to rewrite any URL it won't work with Joomla! as the SEF URL is created by JRoute which uses a combination of the core route function and the route.php for the component.
The URL segments are used to find the right component to handle the request, so to change the way the URL is built you would have to modify the route.php of the component (and obviously other parts as well).
For more information on how SEF support works, read this on docs.joomla.org

how to transfer codeigniter site from localhost to live server

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.

Whats the purpose of Index.php in MVC Frameworks?

I want a good understandable description of index.php in MVC Frameworks... I have worked in Magento and Codeignitor...
In Magento URL's index.php is called front controller but in codeignitor what it is?
Plz clear the concept of index.php in MVC Frameworks?
The index is your entry point from where it will dispatch / route your URL to the appropriate controllers/actions. You don't have to name in index.php though, you can give it whatever name you want, as long as you call the file, it won't be a problem.
In codeigniter index.php is the entry point of the application. Its not a controller. It sets your environment, initializes your config/route/autoload etc. and then loads your requested controller.
Generally, index.php mainly works as a bootstrapper. It initializes all most variables and puts your application in a usable state. Almost all calls are routed through it. If you want you can also hide index.php from your visible path using .htaccess. For example in yii you can use this guide: http://www.yiiframework.com/wiki/214/url-hide-index-php/

Resources