Page 1 of 1

Hướng dẫn cấu hình .htaccess toàn tập (Có bổ sung và sửa chữa)

Posted: Tue, 30/12/2014 10:05 AM
by admin
Chuyển http sang https
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

Bắt buộc dùng HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.huyentienyen.com/tienyen/$1 [R=301,L]

Redirect từ www tới non-www:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.huyentienyen.com [NC]
RewriteRule ^(.*)$ http://huyentienyen.com/$1 [L,R=301]
---------------------------

Redirect từ non-www tới www:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^huyentienyen.com [NC]
RewriteRule ^(.*)$ http://www.huyentienyen.com/$1 [L,R=301]

-------------------

Chỉ định danh mục file index
DirectoryIndex index.html index.php home.htm
----------
################ Hot link cho trang www.huyentienyen.com
RewriteCond %{HTTP_REFERER} !^http://huyentienyen.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://huyentienyen.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.huyentienyen.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.huyentienyen.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
#################### Hot link end

############ Cấu hình PHP.ini cho Subfolder
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/tynnfrhc/public_html
</IfModule>
############ PHP.ini enable in subfolder

----------------