web.config(IIS)和.htaccess(Apache)配置
xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="URL_TO_ALLOW"/> <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS"/> <add name="Access-Control-Allow-Headers" value="Content-Type"/> </customHeaders> </httpProtocol> </system.webServer> </configuration>
forceHTTPS
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Force HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{REQUEST_URI}" negate="true" pattern="/ADD_PATTERM_TO_EXCLUDE_FILES_OR_FOLDERS/" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
browserCaching
# Enables browser caching <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType text/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 2 days" </IfModule>
customErrorPages
# Sets up custom error pages for 4xx and 5xx errors
ErrorDocument 403 /custom-403.html
ErrorDocument 404 /custom-404.html
forceHTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
preventAccessToConfigFiles
# Denies access to all .htaccess files
<Files ~ "^.*\.([Hh][Tt][Aa])">
Order Allow,Deny
Deny from all
Satisfy all
</Files>
urlRewrite
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
好了這篇文章就介紹到這了,需要的朋友可以學(xué)習(xí)一下。
相關(guān)文章
WINPE3.0集成RAID陣列卡驅(qū)動(dòng)的實(shí)現(xiàn)方法
這篇文章主要介紹了WINPE3.0集成RAID陣列卡驅(qū)動(dòng)的實(shí)現(xiàn)方法,需要的朋友可以參考下2016-07-07windows系統(tǒng)搭建WEB服務(wù)器詳細(xì)教程
這篇文章主要為大家詳細(xì)介紹了windows系統(tǒng)搭建WEB服務(wù)器詳細(xì)教程,文中安裝步驟介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08WordPress網(wǎng)站遷移到新主機(jī)防火墻配置
這篇文章主要為大家介紹了WordPress網(wǎng)站遷移到新主機(jī)防火墻配置,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-03-03Vestacp整合WHMCS實(shí)現(xiàn)自動(dòng)銷售開通虛擬主機(jī)服務(wù)教程
這篇文章主要為大家詳細(xì)介紹了Vestacp整合WHMCS實(shí)現(xiàn)自動(dòng)銷售開通虛擬主機(jī)服務(wù)教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Nginx服務(wù)器負(fù)載均衡及ssl原理、生成ssl密鑰對、Nginx配置ssl操作示例
這篇文章通過大量的實(shí)例總結(jié)了nginx服務(wù)器上負(fù)載均衡的概念、配置、ssl原理、密鑰對生成以及nginx服務(wù)器上配置ssl的相關(guān)操作實(shí)現(xiàn)方法2018-05-05完美解決在eclipse上部署Tomcat時(shí)出現(xiàn)8080等端口被占用的問題
下面小編就為大家?guī)硪黄昝澜鉀Q在eclipse上部署Tomcat時(shí)出現(xiàn)8080等端口被占用的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07