Default File .htaccess pada berbagai CMS
Kennaz 13 Juli 2015
Bagi anda yang merupakan web developer, terutama yang menggunakan web server apache, pasti tidak asing lagi dengan file .htaccess. Anda bisa membuat dan mengedit sendiri file ini, namun biasanya tersembunyi karena merupakan sebuah dotfiles. File ini juga ada di beberapa CMS dan framework, silahkan pahami lebih dalam mengenai file htaccess.
Setiap CMS memiliki isi file .htaccess yang berbeda-beda, berikut default file .htaccess pada beberapa CMS.
-
File .htaccess Wordpress.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
-
File .htaccess Joomla.
## # @package Joomla # @copyright Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved. # @license GNU General Public License version 2 or later; see LICENSE.txt ## ## # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE! # # The line just below this section: 'Options +FollowSymLinks' may cause problems # with some server configurations. It is required for use of mod_rewrite, but may already # be set by your server administrator in a way that disallows changing it in # your .htaccess file. If using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your sef url's. If they work, # it has been set by your server administrator and you do not need it set here. ## ## No directory listings IndexIgnore * ## Can be commented out if causes errors, see notes above. Options +FollowSymlinks Options -Indexes ## Mod_rewrite in use. RewriteEngine On ## Begin - Rewrite rules to block out some common exploits. # If you experience problems on your site block out the operations listed below # This attempts to block the most common type of exploit `attempts` to Joomla! # # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F] # ## End - Rewrite rules to block out some common exploits. ## Begin - Custom redirects # # If you need to redirect some pages, or set a canonical non-www to # www redirect (or vice versa), place that code here. Ensure those # redirects use the correct RewriteRule syntax and the [R=301,L] flags. # ## End - Custom redirects ## # Uncomment following line if your webserver's URL # is not directly related to physical file paths. # Update Your Joomla! Directory (just / for root). ## # RewriteBase / ## Begin - Joomla! core SEF Section. # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # # If the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} !^/index\.php # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d # internally rewrite the request to the index.php script RewriteRule .* index.php [L] # ## End - Joomla! core SEF Section.
-
File .htaccess Opencart.
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. # 2. In your opencart directory rename htaccess.txt to .htaccess # For any support issues please visit: http://www.opencart.com Options +FollowSymlinks # Prevent Directoy listing Options -Indexes # Prevent Direct Access to files <FilesMatch "\.(tpl|ini|log)"> Order deny,allow Deny from all </FilesMatch> # SEO URL Settings RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] ### Additional Settings that may need to be enabled for some servers ### Uncomment the commands by removing the # sign in front of it. ### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that. # 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it: # php_flag register_globals off # 2. If your cart has magic quotes enabled, This may work to disable it: # php_flag magic_quotes_gpc Off # 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try # php_value upload_max_filesize 999M # 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields # php_value post_max_size 999M # 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields # php_value max_execution_time 200 # 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields # php_value max_input_time 200
-
File .htaccess Lokomedia.
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ media.php?module=home [L] RewriteRule ^galeri-(.*)\.html$ zoom.php?id=$1 [L] RewriteRule ^album-([0-9]+)-(.*)\.html$ media.php?module=detailalbum&id=$1 [L] RewriteRule ^berita-(.*)-(.*)\.html$ media.php?module=detailberita&id=$1 [L] RewriteRule ^agenda-(.*)\.html$ media.php?module=detailagenda&id=$1 [L] RewriteRule ^statis-(.*)\.html$ media.php?module=halamanstatis&id=$1 [L] RewriteRule ^hasil-pencarian\.html$ media.php?module=hasilcari&id=$1 [L] RewriteRule ^indeks-berita\.html$ media.php?module=indeksberita&id=$1 [L] RewriteRule ^hasil-poling\.html$ media.php?module=hasilpoling&id=$1 [L] RewriteRule ^lihat-poling\.html$ media.php?module=lihatpoling&id=$1 [L] RewriteRule ^profil-kami\.html$ media.php?module=profilkami&id=$1 [L] RewriteRule ^hubungi-kami\.html$ media.php?module=hubungikami&id=$1 [L] RewriteRule ^hubungi-aksi\.html$ media.php?module=hubungiaksi&id=$1 [L] RewriteRule ^semua-berita\.html$ media.php?module=semuaberita&id=$1 [L] RewriteRule ^halberita-(.*)\.html$ media.php?module=semuaberita&halberita=$1 [L] RewriteRule ^kategori-([0-9]+)-(.*)\.html$ media.php? module=detailkategori&id=$1 [L] RewriteRule ^halkategori-([0-9]+)-(.*)\.html$ media.php? module=detailkategori&id=$1&halkategori=$2 [L] RewriteRule ^semua-agenda\.html$ media.php?module=semuaagenda&id=$1 [L] RewriteRule ^halagenda-(.*)\.html$ media.php? module=semuaagenda&halagenda=$1 [L] RewriteRule ^semua-download\.html$ media.php? module=semuadownload&id=$1 [L] RewriteRule ^haldownload-(.*)\.html$ media.php? module=semuadownload&haldownload=$1 [L] RewriteRule ^semua-album\.html$ media.php?module=semuaalbum&id=$1 [L] RewriteRule ^halgaleri-([0-9]+)-(.*)\.html$ media.php? module=detailalbum&id=$1&halgaleri=$2 [L] RewriteRule ^halkomentar-(.*)-([0-9]+)\.html$ media.php? module=detailberita&id=$1&halkomentar=$2 [L] Options All -Indexes </IfModule>
Jika ada pertanyaan tentang artikel Default File .htaccess pada beberapa Content Management System (CMS), silahkan hubungi staf Indowebsite.