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

admin3年前网站建设20

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

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

相关文章

创新网站制作由创意和设计两部分组成

创意性的网站设计总能吸引更多用户的注意。创意企业网站进行设计由创意和设计两部分组成。设计师以设计的形式表达和解释创意性的思想和创意。创意网站进行设计主要内容包括工业设计、建筑工程设计、包装设计、平面设...

IIS7/IIS8 自动跳转到HTTPS的实现方法

IIS7需要先确认是否安装 “URL 重写” 或者 “URL Rewrite” 模块 , 如果您已经安装可以跳过“URL重写”...

行业用品网站怎样建设外链?

建设外链是新站、小站SEO必不可少的。常用的外链建设方法可以参考很久以前的帖子怎样增加外部链接,现在其实还是那些方法。常用方法既然常用,大家又都能用,其效果必然下降。效果最好的外链建设方法是大家经常谈...

网站制作中无效页面的处理方式

在SEO的过程中,我们经常会遇到一些网站出现过期页面,简单理解就是失效的网页,并没有实际的参考价值,比如:电子商务网站的产品页面,由于商品售罄,样式与产品尺寸短缺,它将面临交易关闭的情况,那么这种页面...

建网站的页面策划技巧

当小程序网站建设开发完成之后,可以结合微信公众号、视频号、微信群,构建逐渐的网站建设微信品牌生态圈。 当网站建设商家通过公众号推文为用户提供营销的内容,同时通过推文利用网站建设 用户在感情上的痛感,让...

响应式官网怎么建设比较好?

第一合理的网站架构,当进行响应式网站结构规划时,可以使用max-width,从大屏幕开始向下的规划计划,也可以使用min-width,从小屏幕开始向上的规划计划。使用min-width是一种移动优先的...