[Share] Code HTACCESS pada Pengembangan Aplikasi Dengan Codeigniter By: Fadilah Author Topidesta.wordpress.

com (Boljug Blog) Bismillah... Sebenernya biar takut gak ilang aja kalo taro di blog pribadi mah, ini gw biasa pake 3 code htaccess yang sama intinya mah, ngilaning index.php, tapi karena berhubung gw beloon bin bego script htaccess yang gak gw fahami, gw comot dari dunia Internet, sori sourcenya gw lupa!,, ini dia gw catet diantaranya: Options +FollowSymLinks Options -Indexes DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] RewriteEngine on # Tempat naro folder appplication ini udah custom dari gw RewriteBase /folder/folder_sub/@folder/ # Hide the application and system directories by redirecting the request to index.php RewriteRule ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1/ [L] <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301] RewriteRule ^(.*)/index/?$ $1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ $1 [L,R=301] # 'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] # request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] </IfModule> <IfModule !mod_rewrite.c> # Without mod_rewrite, route 404's to the front controller ErrorDocument 404 /index.php </IfModule> Bonus: Kalo biasanya kita load folder versi development config nya seperti ini:
Silahkan pake .htaaccess yang versi ke-2 kalo strukutur folder seperti ini: $config['base_url'] = 'http://localhost/folder/folder_sub/@folder/';

Nah kalo versi production silahkan pake config ini:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ) ? "https" : "http" ); $config['base_url'] .= "://".$_SERVER['HTTP_HOST']; $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

Semoga Bermanfaat!.

Sign up to vote on this title
UsefulNot useful