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

admin3年前网站建设16

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

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

相关文章

建网站中网页布局与颜色运用基本准则

在网页进行设计的众多环节中,页面布局、颜色搭配是尤为一个重要的环节问题之一。接下来,我们将向您展示如何使您的页面在布局和颜色方面看起来更舒适和美观的五个指南。 首先,让我们来讲讲有关页面的布...

独家揭秘影响SEO排名的17项核心因素

独家揭秘影响SEO排名的17项核心因素 大道至简知易行难是SEO行业中容易遇到的一个砍,很多事情看似简单,但是真正下手操作的时候变得思路模糊、操作不当等,很大一部分原因是由于对于SEO核心本质的理解有...

网站制作需要做到图文搭配

网站制作必然会用到图片,文字,色彩,这三种要素是网站设计的核心内容。所以在进行网页设计的时候,专业的设计师需要对这三块内容进行合理的布局,让每一个因素都发挥它更大的作用。 网页设计中占篇幅最...

2016年在品牌做一个企业网站要多少钱?

2016年在做一个企业网站要多少钱?企业网站建设为敏感的就是费用问题,网络作为专业的建站公司,每天都会接听到客户的电话来询问我们做一个企业网站需要多少钱?其实这个问题在不了解企业的情况下很难去...

网站免费备案服务正式起航

对于大部分想做网站的朋友来说,备案一直是让人头疼的事。不备案的话只能使用境外的虚拟主机或者服务器,但是备案又需要各种繁琐的操作。而且很多虚拟主机服务器商还无法提供备案的服务,这就导致国内到目前为止依然...

网站建设之网站结构有哪些类型

网站建设中,网站的结构类型是非常重要的,一个号的结构能让我们的网站更具有创意,更能够吸引用户。如果您不知道网站的结构类型,很难设计一个出色的网站。今天,小编就给大家介绍4种不同结构类型的网站,让您的网...