配色: 字号:
davechild_mod-rewrite
2012-04-10 | 阅:  转:  |  分享 
  
mod_rewriteCheatSheetbyDaveChild(DaveChild)viacheatography.com/1/cs/4/

mod_rewriteTutorials

http://httpd.apache.org/docs/current/rewrite/

http://www.addedbytes.com/for-beginners/url-rewriti

ng-for-beginners/

http://net.tutsplus.com/tutorials/other/a-deeper-look-at-

mod_rewrite-for-apache/

mod_rewriteRewriteRuleFlags

CChainedwithnextrule

CO=cookieSetspecifiedcookie

E=var:

value

Setenvironmentalvariable“var”to

“value”

FForbidden(403header)

GGone-nolongerexists

H=handlerSethandler

LLast-stopprocessingrules

NNext-continueprocessing

NCCaseinsensitive

NEDonotescapeoutput

NSIgnoreifsubrequest

PProxy

PTPassthrough

R[=code]RedirecttonewURL,withoptionalcode

(seebelow)

QSAAppendquerystring

S=xSkipnextxrules

T=mime-

type

Setmimetype

mod_rewriteRewriteCondFlags

NCCaseinsensitive

ORCombinewithnextruleusing''OR''insteadofthe

defaultof''AND''

RedirectionHeaderCodes

301Movedpermanently

302Movedtemporarily(default)

mod_rewriteDirectives

RewriteEngine

RewriteOptions

RewriteLog

RewriteLogLevel

RewriteLock

RewriteMap

RewriteBase

RewriteCond

RewriteRule



RegularExpressionsSyntax

^Startofstring

$Endofstring

.Anysinglecharacter

(a|b)aorb

(...)Groupsection

[abc]Inrange(a,borc)

[^abc]Notinrange

\sWhitespace

a?Zerooroneofa

aZeroormoreofa

a?Zeroormore,ungreedy

a+Oneormoreofa

a+?Oneormore,ungreedy

a{3}Exactly3ofa

a{3,}3ormoreofa

a{,6}Upto6ofa

a{3,6}3to6ofa

a{3,6}?3to6ofa,ungreedy

\Escapecharacter

[:punct:]Anypunctuationsymbol

[:space:]Anyspacecharacter

[:blank:]Spaceortab

There''sanexcellentregularexpressiontesterat:http:/

/regexpal.com/

mod_rewriteServerVariables:HTTPHeaders

%{HTTP_USER_AGENT}

%{HTTP_REFERER}

%{HTTP_COOKIE}

%{HTTP_FORWARDED}

%{HTTP_HOST}

%{HTTP_PROXY_CONNECTION}

%{HTTP_ACCEPT}

mod_rewriteServerVariables:ServerInternals

%{DOCUMENT_ROOT}

%{SERVER_ADMIN}

%{SERVER_NAME}

%{SERVER_ADDR}

%{SERVER_PORT}

%{SERVER_PROTOCOL}

%{SERVER_SOFTWARE}



mod_rewriteSampleRule:SiteMoved

#Sitemovedpermanently

RewriteCond%{HTTP_HOST}^www.domain.com$

[NC]

RewriteRule^(.)$http://www.domain2.com/$1

[R=301,L]

Rewritesdomain.comtodomain2.com

mod_rewriteSampleRule:TemporaryPageMove

#Pagehasmovedtemporarily

RewriteRule^page.html$new_page.html[R,NC,L]

Rewritesdomain.com/page.htmltodomain.com/new_

page.html

mod_rewriteSampleRule:NiceURLs

#NiceURLs(noquerystring)

RewriteRule^([A-Za-z0-9-]+)/?$categories.php?

name=$1[L]

Rewritesdomain.com/category-name-1/todomain.co

m/categories.php?name=category-name-1

mod_rewriteServerVariables:Special

%{API_VERSION}

%{THE_REQUEST}

%{REQUEST_URI}

%{REQUEST_FILENAME}

%{IS_SUBREQ}

%{HTTPS}

mod_rewriteServerVariables:Request

%{REMOTE_ADDR}

%{REMOTE_HOST}

%{REMOTE_PORT}

%{REMOTE_USER}

%{REMOTE_IDENT}

%{REQUEST_METHOD}

%{SCRIPT_FILENAME}

%{PATH_INFO}

%{QUERY_STRING}

%{AUTH_TYPE}

mod_rewriteServerVariables:Time

%{TIME_YEAR}

%{TIME_MON}

%{TIME_DAY}

%{TIME_HOUR}

%{TIME_MIN}

%{TIME_SEC}

%{TIME_WDAY}

%{TIME}



Cheatographer

DaveChild(DaveChild)

CheatSheet

Thischeatsheetwaspublishedon19thOctober,2011

Sponsor

FeedbackFair,increaseyourconversionratetoday!

cheatography.com/davechild/

www.addedbytes.com

andwaslastupdatedon12thFebruary,2012.Tryitfree!

http://www.FeedbackFair.com

献花(0)
+1
(本文系H1975815首藏)