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

admin3年前网站建设69

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

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

相关文章

如何通过企业网站制作提升企业口碑

企业网站建设旨在打造企业形象,宣传企业品牌,在目标用户中塑造企业口碑。要达到这个目的就需要从网站建设的第一步开始对各个环节优化,以实现有效提升企业口碑。 企业网站的口碑指的是网络用户对于企业...

百度排名突然暴跌或与网站备案有直接关系

百度搜索排名数据,出现巨大波动,诱发大量网站关键词排名突然暴跌甚至消失,大量关键词排名本身在前三的突然就没有排名了。对此,我们将平台数据进行了汇总统计,发现在12月底至今已有200多个词排名暴跌的现象...

IIS服务器性能优化

IIS性能优化1、调整IIS高速缓存HKEY_LOCAL_MACHINE SystemCurrentControlSetServicesInetInfoParametersMemoryCacheSiz...

浅谈网站制作的安全性和完整性

网站制作公司可以认为,一些外部环境是我们必须进行考虑的问题。一个企业健康的网站必须有一个可以定期的备份工作。备份工作的重要性不言而喻。对于我们很多新手站长来说,网站的备份并没有那么受重视,导致企业网站...

怎样评价网站制作效果?三个评判标准

首先,内容结构简明扼要 网站制作的内容结构简洁突出,核心要素突出。那就是让访问者一目了然地看到网站页面的主要内容。网站设计完成后,经常会发现一些内容与设计不一致。我们可以编辑或删除这些内容。...

ApplicationHost.config(IIS存储配置区文件)介绍

对于一个刚刚创建网站,以ASP.NET MVC5为例。我们并没有在网页的配置文件(web.config)中配置一些处理程序或模块,如处理Session的SessionStateModule模块,映射U...