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

admin3年前网站建设66

xml

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?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

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?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="{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
            </rule>
 
            </rules>
        </rewrite>
 
</system.webServer>
</configuration>






browserCaching

?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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
ErrorDocument 404 /custom-404

forceHTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't puthere. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* %{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* %{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]

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

原文链接:blog.csdn/WuLex

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

网站制作方案之网站导航

在企业网站制作规划中,建设一个优秀的、良好的网站导航栏设计应该具有优化的理念设计,它必须满足客户一眼就能清楚看到网站主题内容并能轻松找到感兴趣内容的要求,同时满足搜索引擎可以理清网站建设的基本结构,有...

一天赚1万世界观

前几天,在我的读者群里遇到了一个很牛的人,他说自己有76万个QQ群,但是QQ群不赚钱,不如微信。他有600个微信号,每天收红包就能收1万多,真是收到手软。为了养这600个微信号,他4个月没出门。为了找...

关于讲解企业官网在设计方面需要注意的问题

关于讲解企业官网在设计方面需要注意的问题。今天我们和大家说说企业集团官方网站的制作要注意哪些事项呢。那么官方集团网站到底有哪些注意的呢,下面网站建设根据自己的经验和大家来说说。我们现在做网站根据他们的...

非经营性网站怎么进行备案

我国整个国家都着手响应备案,那我们也不能落后,企业也要指定种种各样的认证标准,用来提升企业的形象和影响力,做得好的企业能够跻身成为行业标准。网站备案这个大家都知道,做过网站建设的人都知道,只要是在中国...

win server 2019服务器的iis配置以及网站的简单发布

1.首先远程连接到服务器2.打开服务器管理器3添加角色和功能4选择从服务器池中选择服务器5服务器角色选择Web服务器(iis)6.功能选择NET Framework3.5全选7.在控制面板&ndash...

为何要备案?

一些企业在起步阶段或是已经获得一定成就后会开拓更宽的发展方向,他们把苗头指向了广阔的互联网,于是一个个企业网站就因此而诞生。然而,在刚接触到网站建设时很多企业负责人都还不了解有备案这个环节,认为只要将...