sondmk header
วิธีการใช้งาน .HTACCESS เบื้องต้น

.htaccess :: Redirect 404 เป็น index.php

Post by Goborijung at 2019-11-26 13:42:58 | ID: 188

// .htaccess :: Redirect 404 เป็น index.php
ErrorDocument 404 /index.php

.htaccess :: Redirect HTTP เป็น HTTPS

Post by Goborijung at 2018-12-24 10:10:17 | ID: 7

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

.htaccess :: Redirect Part ปัจจุบัน เป็น Part ใหม่

Post by Goborijung at 2018-12-24 10:11:44 | ID: 8

RewriteEngine On
Redirect /product.php https://domain.com หรือ
RewriteRule product.php https://domain.com

.htaccess :: Redirect www to non-www || non-www to www

Post by Goborijung at 2018-12-24 10:12:18 | ID: 9

> ทดสอบว่า Mode_Rewrite ทำงานหรือไม่ ด้วยการทดสอบเปิดไฟล์ test.html จะต้องโดน Redirect ไปที่ google.com
RewriteEngine On
RewriteRule ^test.html http://www.google.com/? [R=301,L]

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

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

.htaccess :: Redirect ชื่อไฟล์ใหม่ ให้ไปยัง ชื่อไฟล์เก่า

Post by Goborijung at 2018-12-24 10:09:44 | ID: 6

RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^newname$ filename.php

.htaccess :: การซ่อนนามสกุลไฟล์ .php

Post by Goborijung at 2018-12-24 10:05:43 | ID: 4

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]

.htaccess :: การตั้งค่าหน้าเริ่มต้นใหักับเว็บไซต์

Post by Goborijung at 2018-12-24 10:03:38 | ID: 3

RewriteEngine On
DirectoryIndex index.php page-down.php

.htaccess :: เปลี่ยน index.php ให้เป็น name/

Post by Goborijung at 2019-11-26 13:41:53 | ID: 187

// .htaccess :: เปลี่ยน index.php ให้เป็น name/
RewriteEngine On
RewriteRule ^name/$ index.php //ตรง name จะตั้งชื่อเป็นอะไรก็ได้

.htaccess :: เปลี่ยนชื่อไฟล์ .php เป็น .html

Post by Goborijung at 2018-12-24 10:08:24 | ID: 5

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

.htaccess :: Redirect http://domain.com/abc/product.php?i=1 :: xx.php?i=1 to xx/1

Post by Goborijung at 2020-06-06 09:07:39 | ID: 84

# http://domain.com/abc/product.php?i=1 to http://domain.com/abc/product/1 

RewriteEngine on
RewriteRule product/(.*)/ product.php?i=$1
RewriteRule product/(.*) product.php?i=$1

1

Framework

Library


เครื่องมือพัฒนาเว็บ



การออกแบบและพัฒนาเว็บไซต์


Download SourceCode



copyAllright © 2016 soundmk.com