系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 数据库 > Access > 详细页面

web.config(IIS)和.htaccess(Apache)配置

时间:2019-12-04来源:系统城作者:电脑系统城

xml


 
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <system.webServer>
  4.  
  5. <httpProtocol>
  6. <customHeaders>
  7. <add name="Access-Control-Allow-Origin" value="URL_TO_ALLOW"/>
  8. <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS"/>
  9. <add name="Access-Control-Allow-Headers" value="Content-Type"/>
  10. </customHeaders>
  11. </httpProtocol>
  12.  
  13. </system.webServer>
  14. </configuration>

forceHTTPS


 
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3. <system.webServer>
  4.  
  5. <rewrite>
  6. <rules>
  7.  
  8. <rule name="Force HTTPS" stopProcessing="true">
  9. <match url="(.*)" />
  10. <conditions logicalGrouping="MatchAll">
  11. <add input="{HTTPS}" pattern="off" ignoreCase="true" />
  12. <add input="{REQUEST_URI}" negate="true"pattern="/ADD_PATTERM_TO_EXCLUDE_FILES_OR_FOLDERS/" ignoreCase="true" />
  13. </conditions>
  14. <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true"redirectType="Permanent" />
  15. </rule>
  16.  
  17. </rules>
  18. </rewrite>
  19.  
  20. </system.webServer>
  21. </configuration>

browserCaching


 
  1. # Enables browser caching
  2. <IfModule mod_expires.c>
  3. ExpiresActive On
  4. ExpiresByType image/jpg "access 1 year"
  5. ExpiresByType image/jpeg "access 1 year"
  6. ExpiresByType image/gif "access 1 year"
  7. ExpiresByType image/png "access 1 year"
  8. ExpiresByType text/css "access 1 month"
  9. ExpiresByType application/pdf "access 1 month"
  10. ExpiresByType text/x-javascript "access 1 month"
  11. ExpiresByType application/x-shockwave-flash "access 1 month"
  12. ExpiresByType image/x-icon "access 1 year"
  13. ExpiresDefault "access 2 days"
  14. </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]

好了这篇文章就介绍到这了,需要的朋友可以学习一下。

分享到:

相关信息

  • 让Apache 2支持.htaccess并实现目录加密的方法

    让Apache 2支持.htaccess并实现目录加密的方法,这篇文章主要介绍了让Apache 2支持.htaccess并实现目录加密的方法,文中给出了详细的方法步骤,并给出了示例代码,对大家具有一定的参考价值,...

    2019-12-04

  • 使用.htaccess设置图片防盗链的详细方法

    对于虚拟主机用户来说,最方便的莫过于利用.htaccess设置图片防盗链了。上网搜了一下,.htaccess规则写法很多,但是大部分的区别在于最后一行,下面我们先看看正确的.htaccess防盗链写法,稍后我再详细解释一下最后一行的重点...

    2019-12-04

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载