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

admin3年前网站建设100

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.个性化 网站的个性化特征可以通过页面的布局来...

云蜘蛛时代,搜索排名一夜全自动霸屏?

续松松前段时间博文里写的《3天3万词霸屏外推实战记录》所说的就是利用外推软件,去第三方高权重的站点发帖,引蜘蛛去收录帖子,从而达到了一夜收录上万词霸屏!为何说是云蜘蛛时代快照排名一夜全自动霸屏呢?首先...

建网站如何体现其可用性

网站的可用性不但是我们可以通过访问网站的前提,也为用户能够轻松访问网站提供重要保证,那在建网站中如何充分体现其可用性呢? 1.移动优先的原则 网站的可用性是保证企业所有用户可以同时...

Windows 10安装IIS

现在windows10 已经成为了大家常用的操作系统了,那么 Windows 10 如何安装 IIS 呢?Win10 安装 IIS 的方法与 Win7 非常类似,步骤几乎相同,下面简单分步骤介绍一下:...

不同客户端分辨率下对网站设计中分辨率要求有如下常见问题

不同客户端分辨率下对网站设计中分辨率要求有如下常见问题,严重的时候会出现错位,直接影响到了网站设计方案的观赏性。造成这一现象的原因主要在于网站设计页面中采用了绝对定位。  那么,在实际的网站建设公司操...

网站制作怎么兼顾创新意与搜索引擎优化?

在当前网络发展的时代,企业官网的建设可以帮助企业扩大宣传推广的范围,创造专属的私人领域流量,为企业品牌创造更高的知名度,因为互联网技术的快速发展,官网建设更加全面,用户体验更好,深受用户欢迎,一个好的...