Sie sind auf Seite 1von 14

3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.

htaccessServerRules

.htaccessCheatSheet
AlltheimportantApache.htaccesswebserverrulesandconfigoptions

Welcometoourfastloadingonepage.htaccesscheatsheetwithallmajor.htaccessrules
listed.
Wehavenoads,nojavascript.JustplainHTML(anda.cssfile),soitshouldloadsuperfast.Cominghereand
aquickcmd+f/ctrl+fshouldbefasterthanfindingtheansweronstackexchange:)AlsocheckoutourPHP's
DomDocumentCheatsheet

Rememberthatformostrulesyoumusthavethe RewriteEngineon ruleinyour


.htaccessfile!!!

RewriteandRedirection Security
allowcertainIPs)
ServeAllRequestsWithOnePHP BlockIPAddress
File AllowaccessonlyfromLAN
WordPress.htaccessforpermalinks DenyAccessToCertainUserAgents
Forcewww (bots)
ForcewwwinaGenericWay DenyAccesstoHiddenFilesand
Forcenonwww Directories
ForcenonwwwinaGenericWay DenyAccessToCertainFiles
ForceHTTPS DenyAccesstoBackupandSource
ForceHTTPSBehindaProxy Files
ForceTrailingSlash DisableDirectoryBrowsing
RemoveTrailingSlash EnableDirectoryListings
RedirectaSinglePage DisableListingOfCertainFiletypes(if
AliasaSingleDirectory Indexesisnotdisabled)
AliasPathsToScript DisableImageHotlinking
RedirectanEntireSite

Performance Miscellaneous
ServerVariablesformod_rewrite

http://htaccesscheatsheet.com/ 1/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

CompressTextFiles(gzip/deflate SetPHPVariables
output) CustomErrorPages
SetExpiresHeaders Redirectuserstoamaintenancepage
TurneTagsOff whileyouupdate
LimitUploadFileSize ForceDownloading
DisableShowingServerInfo(Server
Signature)
PreventDownloading
AllowCrossDomainFonts
AutoUTF8Encode
SetServerTimezone(toUTC,or
othertimezone)
SwitchtoAnotherPHPVersion

Pleaseremembertodoublecheckandverifyanyrulesthatyouuse.Ifyoudonot
understandarulepleaseconsultsomeonewhodoes.Weacceptnoresponsibilityforyour
useoftheserulesusethematyourownrisk.Pleasegetintouchifyouwantustoadda
rule!

RewriteandRedirectionRules
(Note:Itisassumedthatyouhave`mod_rewrite`installedandenabled.Thefirstline
shouldbe'RewriteEngineon'toenablethis)

ServeAllRequestsWithOnePHPFilewith.htaccess permlink

RewriteCond%{REQUEST_FILENAME}!f
RewriteCond%{REQUEST_FILENAME}!d
RewriteRule^([^?]*)$/index.php[NC,L,QSA]

WordPress.htaccessforpermalinkswith.htaccess permlink

(ThisistheonlyruleinthissectionthatincludestheRewriteEngineon
rule)

#BEGINWordPress
<IfModulemod_rewrite.c>
RewriteEngineOn
RewriteBase/
RewriteCond%{REQUEST_FILENAME}!f
RewriteCond%{REQUEST_FILENAME}!d
RewriteRule./index.php[L]
</IfModule>
#ENDWordPress
http://htaccesscheatsheet.com/ 2/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

Forcewwwwith.htaccess permlink

RewriteEngineon
RewriteCond%{HTTP_HOST}^example\.com[NC]
RewriteRule^(.*)$http://www.example.com/$1[L,R=301,NC]

ForcewwwinaGenericWaywith.htaccess permlink

RewriteCond%{HTTP_HOST}!^$
RewriteCond%{HTTP_HOST}!^www\.[NC]
RewriteCond%{HTTPS}s^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI}[R=301,L]

Thisworksforanydomain.Source

Forcenonwwwwith.htaccess permlink

It'sstillopenfordebatewhetherwwwornonwwwisthemasterrace,so
ifyouhappentobeafanorbaredomains,hereyougo:

RewriteEngineon
RewriteCond%{HTTP_HOST}^www\.example\.com[NC]
RewriteRule^(.*)$http://example.com/$1[L,R=301]

ForcenonwwwinaGenericWaywith.htaccess permlink

RewriteEngineon
RewriteCond%{HTTP_HOST}^www\.
RewriteCond%{HTTPS}s^on(s)|off
RewriteCondhttp%1://%{HTTP_HOST}^(https?://)(www\.)?(.+)$
RewriteRule^%1%3%{REQUEST_URI}[R=301,L]

ForceHTTPSwith.htaccess permlink

UsethistoredirectnonHTTPSrequeststoaHTTPSrequest.I.e.ifyou
gotohttp://example.com/itwillredirecttohttps://example.com.

RewriteEngineon
RewriteCond%{HTTPS}!on
RewriteRule(.*)https://%{HTTP_HOST}%{REQUEST_URI}

ItisrecommendedtouseHSTS(readaboutitonWikipedia)though.

"HTTPStrictTransportSecurity(HSTS)isawebsecuritypolicy
mechanismwhichisnecessarytoprotectsecureHTTPSwebsites
againstdowngradeattacks,andwhichgreatlysimplifiesprotection
againstcookiehijacking.Itallowswebserverstodeclarethatweb
browsers(orothercomplyinguseragents)shouldonlyinteractwithit
usingsecureHTTPSconnections,andneverviatheinsecureHTTP
protocol.HSTSisanIETFstandardstrackprotocolandisspecifiedin
RFC6797."

http://htaccesscheatsheet.com/ 3/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

ForceHTTPSBehindaProxywith.htaccess permlink

UsefulifyouhaveaproxyinfrontofyourserverperformingTLS
termination.

RewriteCond%{HTTP:XForwardedProto}!https
RewriteRule(.*)https://%{HTTP_HOST}%{REQUEST_URI}

ForceTrailingSlashwith.htaccess permlink

Usethefollow.htaccessruletoredirectanyurlstothesameurl(but
withatrailingslash)foranyrequeststhatdonotendwithatrailing
slash.I.e.redirectfromhttp://example.com/yourpageto
http://example.com/yourpage/

RewriteCond%{REQUEST_URI}/+[^\.]+$
RewriteRule^(.+[^/])$%{REQUEST_URI}/[R=301,L]

RemoveTrailingSlashwith.htaccess permlink

Usethistoremoveanytrailingslash(itwill301redirecttothenon
trailingslashurl)

RewriteCond%{REQUEST_FILENAME}!d
RewriteRule^(.*)/$/$1[R=301,L]

RedirectaSinglePagewith.htaccess permlink

RedirectasingleURLtoanewlocation

Redirect301/oldpage.htmlhttp://www.yoursite.com/newpage.html
Redirect301/oldpage2.htmlhttp://www.yoursite.com/folder/

Source

AliasaSingleDirectorywith.htaccess permlink

RewriteEngineOn
RewriteRule^sourcedirectory/(.*)targetdirectory/$1

AliasPathsToScriptwith.htaccess permlink

RewriteEngineOn
RewriteRule^$index.fcgi/[QSA,L]
RewriteCond%{REQUEST_FILENAME}!f
RewriteCond%{REQUEST_FILENAME}!d
RewriteRule^(.*)$index.fcgi/$1[QSA,L]

Thisexamplehasan index.fcgi fileinsomedirectory,andanyrequests


withinthatdirectorythatfailtoresolveafilename/directorywillbesent
tothe index.fcgi script.It'sgoodifyouwant baz.foo/some/cool/path to
http://htaccesscheatsheet.com/ 4/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

behandledby baz.foo/index.fcgi (whichalsosupportsrequeststo


baz.foo )whilemaintaining baz.foo/css/style.css andthelike.

RedirectanEntireSitewith.htaccess permlink

Usethefollowing.htaccessruletoredirectanentiresitetoanew
location/domain

Redirect301/http://newsite.com/

Thiswaydoesitwithlinksintact.Thatis
www.oldsite.com/some/crazy/link.html willbecome
www.newsite.com/some/crazy/link.html .Thisisextremelyhelpfulwhen
youarejust"moving"asitetoanewdomain.

Source

Alias"Clean"URLswith.htaccess permlink

Thissnippetletsyouuse"cleanURLs"thosewithoutaPHP
extension,e.g. example.com/users insteadof example.com/users.php .

RewriteEngineOn
RewriteCond%{SCRIPT_FILENAME}!d
RewriteRule^([^.]+)$$1.php[NC,L]

Source

SecurityRules

DenyAllAccesswith.htaccess permlink

Ifyouwanttopreventapacheservinganyfilesatall,usethefollowing.
Apache2.2:

Denyfromall

Apache2.2:

#Requirealldenied

Thiswillstopyoufromaccessingyourwebsite.Ifyouwanttodenyall
accessbutstillbeabletoviewityourselfpleasereadthenextrule:

http://htaccesscheatsheet.com/ 5/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

DenyAllAccessExceptYours(OnlyallowcertainIPs)with
.htaccess permlink

UsethistoONLYallowcertainIPaddressestoaccessyourwebsite.
Apache2.2

Orderdeny,allow
Denyfromall
Allowfromxxx.xxx.xxx.xxx

Apache2.4

#Requirealldenied
#Requireipxxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx isyourIP.Ifyoureplacethelastthreedigitswith0/12
forexample,thiswillspecifyarangeofIPswithinthesamenetwork,
thussavingyouthetroubletolistallallowedIPsseparately.Source

Pleaseseethenextruleforthe'opposite'ofthisrule!

BlockIPAddresswith.htaccess permlink

ThiswillallowaccesstoallIPsEXCEPTtheoneslisted.Youcanuse
thistoallowallaccessExceptSpammer'sIPaddresses.

Replacexxx.xxx.xxx.xxxandxxx.xxx.xxx.xxywiththeIPaddressesyou
wanttoblock.
Apache2.2

Orderdeny,allow
Allowfromall
Denyfromxxx.xxx.xxx.xxx
Denyfromxxx.xxx.xxx.xxy

Apache2.4

#Requireallgranted
#Requirenotipxxx.xxx.xxx.xxx
#Requirenotipxxx.xxx.xxx.xxy

AllowaccessonlyfromLANwith.htaccess permlink

orderdeny,allow
denyfromall
allowfrom192.168.0.0/24

DenyAccessToCertainUserAgents(bots)with.htaccess
permlink
Usethis.htaccessruletoblock/bancertainuseragents

RewriteCond%{HTTP_USER_AGENT}^User\Agent\1[OR]
RewriteCond%{HTTP_USER_AGENT}^Another\Bot\You\Want\To\Block[OR]
RewriteCond%{HTTP_USER_AGENT}^Another\UA
RewriteRule^.*[F,L]

http://htaccesscheatsheet.com/ 6/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

DenyAccesstoHiddenFilesandDirectorieswith.htaccess
permlink
Hiddenfilesanddirectories(thosewhosenamesstartwithadot
. )shouldmost,ifnotall,ofthetimebesecured.Forexample:
.htaccess , .htpasswd , .git , .hg ...

RewriteCond%{SCRIPT_FILENAME}d[OR]
RewriteCond%{SCRIPT_FILENAME}f
RewriteRule"(^|/)\."[F]

Alternatively,youcanjustraisea NotFound error,givingtheattacker


dudenoclue:

RedirectMatch404/\..*$

DenyAccessToCertainFileswith.htaccess permlink

Usethistoblockordenyaccesstocertainfiles

<filesyourfilename.txt>
orderallow,deny
denyfromall
</files>

DenyAccesstoBackupandSourceFileswith.htaccess
permlink
Thesefilesmaybeleftbysometext/htmleditors(likeVi/Vim)
andposeagreatsecuritydanger,whenanyonecanaccessthem.

<FilesMatch"(\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
##Apache2.2
Orderallow,deny
Denyfromall
SatisfyAll

##Apache2.4
#Requirealldenied
</FilesMatch>

Source

DisableDirectoryBrowsingwith.htaccess permlink

OptionsAllIndexes

EnableDirectoryListingswith.htaccess permlink

OptionsAll+Indexes

DisableListingOfCertainFiletypes(ifIndexesisnot
disabled)with.htaccess permlink

http://htaccesscheatsheet.com/ 7/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

UsethistoexcludecertainfiletypesfrombeinglistedinApache
directorylisting.Youcouldusethistostop.pdffiles,orvideofiles
showingup.

IndexIgnore*.zip*.mp4*.pdf

DisableImageHotlinkingwith.htaccess permlink

RewriteEngineon
RewriteCond%{HTTP_REFERER}!^$
RewriteCond%{HTTP_REFERER}!^http(s)?://(www\.)?yourdomain.com[NC]
RewriteRule\.(jpg|jpeg|png|gif)$[NC,F,L]

Redirecthotlinkersandshowadifferentimagewith
.htaccess permlink

RewriteCond%{HTTP_REFERER}!^$
RewriteCond%{HTTP_REFERER}!^http://(www\.)?yourwebsite.com/.*$[NC]
RewriteRule\.(gif|jpg|png)$http://www.yourwebsite.com/donothotlinkourcontent.jpg[R,L]

DenyAccessfromcertainreferrerswith.htaccess permlink

Usethisruletoblockaccesstorequeststhatincludeareferrerfroma
certaindomain.

RewriteCond%{HTTP_REFERER}blockthisreferer\.com[NC,OR]
RewriteCond%{HTTP_REFERER}andblocktrafficthatthissitesends\.com[NC]
RewriteRule.*[F]

PasswordProtectaDirectorywith.htaccess permlink

Firstyouneedtocreatea .htpasswd filesomewhereinthesystem.Run


thefollowingcommandatthecommandline:

htpasswdc/home/hidden/directory/here/.htpasswdthe_username

Thenyoucanuseitforauthentication.Inyour.htaccessfileyouneed
somethinglikethefollowingcode,butmakesuretheAuthUserFileisthe
filepathtothe.htpasswdyoujustcreated.Youshouldkeepthe
.htpasswdinadirectorynotaccesibleviatheweb.Sodon'tputitinyour
/public_html/or/www/directory.

AuthTypeBasic
AuthName"PasswordProtectedDirTitle"
AuthUserFile/home/hidden/directory/here/.htpasswd
Requirevaliduser

PasswordProtectaFileorSeveralFileswith.htaccess
permlink

http://htaccesscheatsheet.com/ 8/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

AuthName"PasswordProtectedDirectoryTitle"
AuthTypeBasic
AuthUserFile/home/hidden/directory/here/.htpasswd

<Files"aprivatefile.txt">
Requirevaliduser
</Files>

<FilesMatch^((one|two|three)rings?\.o)$>
Requirevaliduser
</FilesMatch>

PerformanceRules

CompressTextFiles(gzip/deflateoutput)with.htaccess
permlink
<IfModulemod_deflate.c>

#Forcecompressionformangledheaders.
#http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushingbeyondgzipping
<IfModulemod_setenvif.c>
<IfModulemod_headers.c>
SetEnvIfNoCase^(AcceptEncodXng|XceptEncoding|X{15}|~{15}|{15})$^((g
RequestHeaderappendAcceptEncoding"gzip,deflate"env=HAVE_AcceptEncod
</IfModule>
</IfModule>

#CompressalloutputlabeledwithoneofthefollowingMIMEtypes
#(forApacheversionsbelow2.3.7,youdon'tneedtoenable`mod_filter`
#andcanremovethe`<IfModulemod_filter.c>`and`</IfModule>`lines
#as`AddOutputFilterByType`isstillinthecoredirectives).
<IfModulemod_filter.c>
AddOutputFilterByTypeDEFLATEapplication/atom+xml\
application/javascript\
application/json\
application/rss+xml\
application/vnd.msfontobject\
application/xfontttf\
application/xwebappmanifest+json\
application/xhtml+xml\
application/xml\
font/opentype\
image/svg+xml\
image/xicon\
text/css\
text/html\
text/plain\
text/xcomponent\
text/xml
</IfModule>

</IfModule>

Source

SetExpiresHeaderswith.htaccess permlink

Expiresheaderstellthebrowserwhethertheyshouldrequestaspecific
filefromtheserverorjustgrabitfromthecache.Itisadvisabletoset
staticcontent'sexpiresheaderstosomethingfarinthefuture.

Ifyoudon'tcontrolversioningwithfilenamebasedcachebusting,
considerloweringthecachetimeforresourceslikeCSSandJSto
http://htaccesscheatsheet.com/ 9/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

somethinglike1week.Source

<IfModulemod_expires.c>
ExpiresActiveon
ExpiresDefault"accessplus1month"

#CSS
ExpiresByTypetext/css"accessplus1year"

#Datainterchange
ExpiresByTypeapplication/json"accessplus0seconds"
ExpiresByTypeapplication/xml"accessplus0seconds"
ExpiresByTypetext/xml"accessplus0seconds"

#Favicon(cannotberenamed!)
ExpiresByTypeimage/xicon"accessplus1week"

#HTMLcomponents(HTCs)
ExpiresByTypetext/xcomponent"accessplus1month"

#HTML
ExpiresByTypetext/html"accessplus0seconds"

#JavaScript
ExpiresByTypeapplication/javascript"accessplus1year"

#Manifestfiles
ExpiresByTypeapplication/xwebappmanifest+json"accessplus0seconds"
ExpiresByTypetext/cachemanifest"accessplus0seconds"

#Media
ExpiresByTypeaudio/ogg"accessplus1month"
ExpiresByTypeimage/gif"accessplus1month"
ExpiresByTypeimage/jpeg"accessplus1month"
ExpiresByTypeimage/png"accessplus1month"
ExpiresByTypevideo/mp4"accessplus1month"
ExpiresByTypevideo/ogg"accessplus1month"
ExpiresByTypevideo/webm"accessplus1month"

#Webfeeds
ExpiresByTypeapplication/atom+xml"accessplus1hour"
ExpiresByTypeapplication/rss+xml"accessplus1hour"

#Webfonts
ExpiresByTypeapplication/fontwoff2"accessplus1month"
ExpiresByTypeapplication/fontwoff"accessplus1month"
ExpiresByTypeapplication/vnd.msfontobject"accessplus1month"
ExpiresByTypeapplication/xfontttf"accessplus1month"
ExpiresByTypefont/opentype"accessplus1month"
ExpiresByTypeimage/svg+xml"accessplus1month"
</IfModule>

TurneTagsOffwith.htaccess permlink

ByremovingtheETagheader,youdisablecachesandbrowsersfrom
beingabletovalidatefiles,sotheyareforcedtorelyonyourCache
ControlandExpiresheader.Source

<IfModulemod_headers.c>
HeaderunsetETag
</IfModule>
FileETagNone

LimitUploadFileSizewith.htaccess permlink

Putthefilesizeinbytes.Seehereforaconversiontool.Thecode
belowlimitsitto1mb.

http://htaccesscheatsheet.com/ 10/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

LimitRequestBody1048576

MiscellaneousRules

ServerVariablesformod_rewritewith.htaccess permlink

%{API_VERSION}
%{DOCUMENT_ROOT}
%{HTTP_ACCEPT}
%{HTTP_COOKIE}
%{HTTP_FORWARDED}
%{HTTP_HOST}
%{HTTP_PROXY_CONNECTION}
%{HTTP_REFERER}
%{HTTP_USER_AGENT}
%{HTTPS}
%{IS_SUBREQ}
%{REQUEST_FILENAME}
%{REQUEST_URI}
%{SERVER_ADDR}
%{SERVER_ADMIN}
%{SERVER_NAME}
%{SERVER_PORT}
%{SERVER_PROTOCOL}
%{SERVER_SOFTWARE}
%{THE_REQUEST}

SetPHPVariableswith.htaccess permlink

php_value<key><val>

Forexample:

php_valueupload_max_filesize50M
php_valuemax_execution_time240

CustomErrorPageswith.htaccess permlink

ErrorDocument500"Houston,wehaveaproblem."
ErrorDocument401http://error.yourdomain.com/mordor.html
ErrorDocument404/errors/halflife3.html

Redirectuserstoamaintenancepagewhileyouupdate
with.htaccess permlink

Thiswillredirectuserstoamaintenancepagebutallowaccesstoyour
IPaddress.Change555.555.555.555toyourIP,and
YourMaintenancePageFilenameOrFullUrlUrl.htmltoyourerrorpage(or
awholeURL,onadifferentdomain).

ErrorDocument403YourMaintenancePageFilenameOrFullUrlUrl.html
Orderdeny,allow
Denyfromall
Allowfrom555.555.555.555

ForceDownloadingwith.htaccess permlink

http://htaccesscheatsheet.com/ 11/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

Sometimesyouwanttoforcethebrowsertodownloadsomecontent
insteadofdisplayingit.Thefollowingsnippetwillhelp.

<Files*.md>
ForceTypeapplication/octetstream
HeadersetContentDispositionattachment
</Files>

DisableShowingServerInfo(ServerSignature)with
.htaccess permlink

Whilemanypeopleconsiderthispointless(especiallywithregardsto
security),ifyouwanttostopyourserverfromgivingawayserverinfo
(theseverOSetc),usethis:

ServerSignatureOff

PreventDownloadingwith.htaccess permlink

Sometimesyouwanttoforcethebrowsertodisplaysomecontent
insteadofdownloadingit.Thefollowingsnippetwillhelp.

<FilesMatch"\.(tex|log|aux)$">
HeadersetContentTypetext/plain
</FilesMatch>

AllowCrossDomainFontswith.htaccess permlink

CDNservedwebfontsmightnotworkinFirefoxorIEduetoCORS.The
followingsnippetfromalrrashouldmakeithappen.

<IfModulemod_headers.c>
<FilesMatch"\.(eot|otf|ttc|ttf|woff|woff2)$">
HeadersetAccessControlAllowOrigin"*"
</FilesMatch>
</IfModule>

AutoUTF8Encodewith.htaccess permlink

TohaveApacheautomaticallyencodeyourcontentinUTF8,usethe
followingcode.Youcanalsoswaptheutf8foranothercharactersetif
required:

#UseUTF8encodingforanythingservedtext/plainortext/html
AddDefaultCharsetutf8

#ForceUTF8foranumberoffileformats
AddCharsetutf8.atom.css.js.json.rss.vtt.xml

Source

http://htaccesscheatsheet.com/ 12/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

SetServerTimezone(toUTC,orothertimezone)with
.htaccess permlink

SetEnvTZUTC

Seealistoftimezoneshere.TosetittoLosAngelestimezone:

SetEnvTZAmerica/Los_Angeles

SwitchtoAnotherPHPVersionwith.htaccess permlink

Ifyou'reonasharedhost,chancesaretherearemorethanoneversion
ofPHPinstalled,andsometimesyouwantaspecificversionforyour
website.Forexample,LaravelrequiresPHP>=5.4.Thefollowing
snippetshouldswitchthePHPversionforyou.

AddHandlerapplication/xhttpdphp55.php

Alternatively,youcanuseAddType

AddTypeapplication/xhttpdphp55.php

DisableInternetExplorerCompatibilityView
CompatibilityViewinIEmayaffecthowsomewebsitesaredisplayed.
ThefollowingsnippetshouldforceIEtousetheEdgeRenderingEngine
anddisabletheCompatibilityView.

<IfModulemod_headers.c>
BrowserMatchMSIEismsie
HeadersetXUACompatibleIE=edgeenv=ismsie
</IfModule>

ExecutePHPwithadifferentfileextensionwith.htaccess
permlink
Thefollowingcodewillrunfilesendingin.extwithphp:

AddTypeapplication/xhttpdphp.ext

ServeWebPImagesAutomaticallyIfTheyExist
IfWebPimagesaresupportedandanimagewitha.webpextension
andthesamenameisfoundatthesameplaceasthejpg/pngimage
thatisgoingtobeserved,thentheWebPimageisservedinstead.

RewriteEngineOn
RewriteCond%{HTTP_ACCEPT}image/webp
RewriteCond%{DOCUMENT_ROOT}/$1.webpf
RewriteRule(.+)\.(jpe?g|png)$$1.webp[T=image/webp,E=accept:1]

AdditionalResources:Other.htaccessCheatsheetsFromAroundtheWeb

http://htaccesscheatsheet.com/ 13/14
3/23/2017 .htaccessCheatSheetAllRulesYouWillEverNeed,ListedOnOnePageforApache.htaccessServerRules

Anothercheatsheetbutin.pdfformat
ApacheRewriteCheatsheet
htaccesscheatsheetonTheJackol
ApacheDocsformod_rewrite
Anotherhtaccesscheatsheet
ModRewriteCheatsheet

Thiswebsiteis100%freeandoneofthefastestloading
Apache.htaccesscheatsheetwebpagesontheweb.Itis
allononepage,andoptimisedtohelpitquicklyloadand
foryoutoeasilyfindthe.htaccessrulesyouneed.Please
getintouchifyouhaveanyquestions.Wewillsoonoffer
thispageasapdfdownload.

Ifyouusethispleaseconsiderlinkingbackto
http://htaccesscheatsheet.com/

Basedheavily(onitsfirstversion)fromphanan/htaccess.

Snippetswithspecifiedsourcebelongtotheirrespective
ownersandhavetheirownlicense(s),whenever
appropriate.

Othercontentbelongstothepublicdomain.Referto
Unlicenseformoreinformation.

HomeContact/AboutusPHP'sDomDocumentCheatsheetTermsandConditions
Wedonotsetanycookiesonourwebsite.Pleaserefertoourprivacypolicyformore
detailsaboutourcookies.

http://htaccesscheatsheet.com/ 14/14

Das könnte Ihnen auch gefallen