Category: Apache
htaccess Redirecting non-www to www
ทำการ redirect จากไม่มี www ข้างหน้าให้เป็น www.sudej.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sudej.com
RewriteRule (.*) http://www.sudej.com/$1 [R=301,L]
</IfModule>
mod rewrite sub directory & not redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) page.pl?variable=$1 [L]
</IfModule>
Apache Mod Rewrite [Flags]
chain|C‘ (chained with next rule)cookie|CO=NAME:VAL:domain[:lifetime[:path]]’ (set cookie)- ‘
env|E=VAR:VAL‘ (set environment variable) - ‘
forbidden|F‘ (force URL to be forbidden) gone|G‘ (force URL to be gone)- ‘
last|L‘ (last rule) - ‘
next|N‘ (next round) nocase|NC‘ (no case)- ‘
noescape|NE‘ (no URI escaping of output) - ‘
nosubreq|NS‘ ( not for internal sub-requests) - ‘
proxy|P‘ (force proxy) - ‘
passthrough|PT‘ (pass through to next handler) - ‘
qsappend|QSA‘ (query string append) - ‘
redirect|R[=code]‘ (force redirect) - ‘
skip|S=num‘ (skip next rule(s)) - ‘
type|T=MIME-type‘ (force MIME type)