2016年8月25日 星期四

CodeIgniter 網址列 index.php去除備忘

之前嘗試失敗的今天成功了,備忘一下...主要差別在httpd.conf AllowOverride沒設成 ALL所致。現在URL看起來清爽多了。

1. ../.htaccess增加
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

2. 在../application/config/config.php
$config['index_page'] = ''; 原:'index.php'

3. vim httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so => 去掉#
AllowOverride None=> AllowOverride All

At Ubuntu 16.04

aptitude reinstall apache2.2-common
a2enmod headers
sudo a2enmod rewrite
service apache2 restart

沒有留言: