[share] Code Htaccess Untuk Pengembangan Web Pada Codeigniter

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]


 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]

 # Without mod_rewrite, route 404's to the front controller
 ErrorDocument 404 /index.php

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']);

Neh kalo yang mau donglot pdfnya:

Semoga Bermanfaat!.

Leave a comment

2 Comments

  1. mantap dh… lanjutkan

    Reply
  1. [share] .htaccess codeigniter dan phalcon di 1 xampp | menulis dibalik topi dan kopi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: