Welcome Guest, Not a member yet? Register   Sign In
Call default controller + default method
#1

[eluser]enigmas[/eluser]
Hi guys, could you please help me to fix one problem.

I'm trying to make new site with CodeIgniter, but wanna to save links compatibility with the older site.

Now, when I open a page of the site written with CodeIgniter, I have to enter following url:
Code:
http://mysite.com/index.php/controller/method/parameter1/parameter2
But is it possible to remove "index.php/controller/method" from this link?

There is no problem to remove "index.php" from url, but maybe there is some way to remove controller and method from the url? Maybe somehow set default controller + default method in CodeIgniter?

Finally I want to open the page just with similar url:
Code:
http://mysite.com/parameter1/parameter2

Is it possible?
#2

[eluser]Rogier[/eluser]
I think you can for the default controller (set in routes) and default method index()... Rewrite the Rule in the htaccess with the specified controller and method. However you can't call other methods and controllers... Cause you made the controller and method static.. I don't know why you should want this.. but okay...

greets
#3

[eluser]enigmas[/eluser]
Hi rogerstreets, thanks you for the reply...

The purpose of this is very simple..imagine I opened download page of my old site with the link
http://mysite.com/en/download.html - english page
http://mysite.com/cn/download.html - chinese page

I want to keep all the links in new site also (to save the google rank position, keep old links etc).

Now, when I need to call download page, i have to enter:
http://mysite.com/controller/method/english/download/ where english/download - parameters for the method..

Maybe you can advise any other better solution how to keep old links?
#4

[eluser]Rogier[/eluser]
You want to maintain the old link which is "http://mysite.com/en/download.html". So that google does not need to index the pages again. Right? Well that is probably the best solution for that problem but you need to complete the link by adding .html add the end.. cause http://mysite.com/en/download.html and http://mysite.com/en/download/ are not the same.

normally you would call the method download/en/ or something...
#5

[eluser]enigmas[/eluser]
Just wanna post a solution for this problem, hope it will be useful!

There is a file application/config/route.php - there we may re-route the requests.

So, if I need the url "http://mysite.com/cn/download.html" to be opened with the codeigniter, I just wrote in the file simple string

$route["cn/download.html"] = 'main/index/en/download';

if you need more pages to re-route, you may add more strings!




Theme © iAndrew 2016 - Forum software by © MyBB