mod rewrite

mod rewrite



REGULAR EXPRESSION SYNTAX

A

Start of string

$

End of string

Any single character

(a|b)

a or b

(...)

Group section

[abcj

Item in rangę (a or b or c)

[Aabc]

Not in rangę (not a or b or c)

a?

Zero or one of a

a*

Zero or morę of a

a+

One or morę of a

a{3>

Exactly 3 of a

a{3,>

3 or morę of a

a{3,6>

Between 3 and 6 of a

l(pattern)

"Not" prefix. Apply rule when URL does not match pattern.


Redirection Header Codes

301

Moved permanently

302

Moved temporarily

403

Forbidden

404

Not Found

410

Gone


RewriteRule FLAGS

R[=code]

Redirect to new URL, with optional codę (see below).

F

Forbidden (sends 403 header)

G

Gone (no longer exists)

P

Proxy

L

Last Rule

N

Next (i.e. restart rules)

C

Chain

T=mime-type

Set Mime Type

NS

Skip if internal sub-request

NC

Case insensitive

QSA

Append query string

NE

Do not escape output

PT

Pass through

S=x

Skip next x rules

E=var:value

Set environmental variable "var" to "value".


RewriteCond FLAGS

NC

Case insensitive

OR

Allows a rule to apply if one of

a senes of conditions are true.


Server Variables


Format

%{NAME_OF_VAR>

HTTP Headers

HTTP_USER_AGENT

HTTP_REFERER

HTTP_COOKIE

HTTP_FORWARDED

HTTP_HOST

HTTP_PROXY_CONNECTION

HTTP_ACCEPT


Rcqucst

REMOTE_ADDR

REMOTE_HOST

REMOTE_USER

REMOTE_IDENT

REQUEST_METHOD

SCRIPT_FILENAME

PATHJNFO

QUERY STRING

AUTH TYPE


Example Rules


#    Site has permanently moved to new domain

#    domain.com to domain2.com

RewriteCond %{HTTP_HOST> Awww.domain.com$ [NC]

RewriteRule A(.*)$ http://www.domain2.com/$l [R=301,L]

#    Page has moved temporarily

#    domain.com/page.htm to domain.com/new_page.htm RewriteRule Apage.htm$ new_page.htm (R,NC,L)

#    Nice looking URLs (no querystring)

#    domain.com/category-name-l/ to domain.com/categories.php?name=category-name-l RewriteRule A([A-Za-zO-9-] + )/?$ categories.php?name=$l [L]

#    Nice looking URLs (no querystring) with pagination

#    domain.com/articles/title/5/ to domain.com/article.php?name=title&page=5 RewriteRule Aarticles/([A-Za-z0-9-]+)/([0-9] + )/?S article.php?name=Sl&page=S2 [L]

#    Błock referrer spam

RewriteCond %{HTTP_REFERER> (weight) (NC.ORJ RewriteCond %{HTTP_REFERER> (drugs) [NCJ RewriteRule .*    -    [F]


Server

DOCUMENT ROOT

SERVER ADMIN

SERVER_ NAME

SERVER_ADDR

SERVER_PORT

SERVER_PROTOCOL

SERVER_SOFTWARE

Time

TIME.YEAR

TIME_MON

TIME_DAY

TIMEJHOUR

TIME_MIN

TIME_SEC

TIME_WDAY

TIME

Special

API_VERSION

THE_REQUEST

REQUEST_URI

REQUEST_FILENAME

IS_SUBREQ


Directives

RewriteEngine

RewriteOptions

RewriteLog

RewriteLogLevel

RewriteLock

RewriteMap

RewriteBase

RewriteCond

RewriteRule


Available free from www.ILoveJackDaniels.com


Wyszukiwarka

Podobne podstrony:
ICT 242 THEORY OF COMPUTATION Deterministic and nondeterministic automata; regular expressions; pump
img352 0: mar<-pc;rd;    / start of rnain loop 1: pc<-pc+l;rd;   &nbs
img353 0: mar<-pc;rd;    / start of rnain loop 1: pc<-pc+l;rd;   &nbs
Picture0 Color Expression and Special Effects Color is expressed in terms of differences in gray Wh
lilo (2) --vi - Hint: Filo files containing regułar expressions • * □ XWindow Pliku Edit Srch/Replce
Course Policies Agreement (5 pts): At the start of the semester students will electronically sign a
mod rewrite fig1
mod rewrite fig2 RewciteCond TestSt ringi CondPattemł_^ RewciteCond ■ Jz£
Pre-primary education is provided for children between the age of 3 and the start of education in th
SYNTAX - part of grammar next to morphology, phonology, and semantics o studies combining words, how
EXPERIMENTAL ANALYSIS OF THE CORRECTION FACTOR f expresses the ratio of W / W. Harkins and Brown fou
S6302331 REGULACJA RZEK I POTOKÓW TRAINING OF RIVERS AND MOUNTAIN STREAMS REGELUNG DER FLGSSE UND BA

więcej podobnych podstron