开发者

Rewrite to case insensitive urls in CodeIgniter site?

I'm using CodeIgniter for a web application, and now I have an urgent question: I just discovered that urls are case sensitive in Linux based servers, and I have just moved a site from Windows to Linux. This means links to the site don't work anymore where there are now all lower-case urls, which were not before.

Googling I found that you should be able to开发者_运维百科 do something like this in the .htaccess file:

RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

But I tried that and it was not good at all...! Suddenly I got a big ugly error page staring at me instead, saying that there must be something wrong with the Tomcat server or something like that. Needless to say I removed those lines immediately!

But why didn't it work then, and what should I do instead?

Any help would be greatly appreciated.


Code igniter supports regular expressions - if you'd like to be explicit in the definition of your routes, define them in this fashion to be case insensitive:

$route['(?i)(about\/contact)'] = 'about/contact';


If case insensitive routes are required, do below changes to URI.php

Location of File: system/core/URI.php

Find $this->_parse_request_uri() and replace it with strtolower($this->_parse_request_uri())


Actually found out that it was quite easy, surprised that no one answered this (perhaps it isn't the correct way, but I would think so...):

I just added some routes in the routes.php file in the config folder:

$route['About/Contact'] = "about/contact";

And so on...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜