Categories
木有技术

CodeIgniter 在Linux(Ubuntu等)服务器上的大小写问题,开启rewrite(.htaccess)

貌似会碰到大小写问题,目前用的CodeIgniter 3.0版,载入的时候发现Controller不显示
首先需要开启mode_rewrite,就是对.htaccess的支持(如果不是root账户记得sudo)

a2enmod rewrite

然后再配置文件中对站点启用rewrite
可以更改sites-available目录下各个虚拟主机的配置文件,默认的应是default那个,差不多有这么一段

<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory>

里面那个AllowOverride 原来是None的,改成All
然后保存文件
另外也有说可以在apache2的默认配置文件下改的,对应到ubuntu下是/etc/apache2/apache.conf。不过这个没试过
然后这一步是开启了mode_rewrite
接下来是要启动那个大小写自动修正的模块,叫mode_speling

a2enmod speling

然后重启apache应用配置

service apache2 restart

接着找到要应用的网站目录,我是直接放在根目录下的,新建一个叫.htaccess的文件,里头是这些

<IfModule mod_speling.c>    
CheckCaseOnly on
    CheckSpelling on
</IfModule>

然后就搞定了。
另外,需要删掉CodeIgniter那个烦人的index.php前缀的话,可以参考文档:http://www.codeigniter.com/user_guide/general/urls.html?highlight=url
Ref: https://www.a2hosting.com/kb/developer-corner/apache-web-server/using-the-mod-speling-apache-module

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.