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

admin3年前网站建设99

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、用一种颜色。这里是指先选定一种颜色,然后调整透明度或者饱和度,产生新的颜色用于网站。这样的页面看起来颜色统...

关于网站应用程序池的帐号密码更改及其影响的实例分析

实例场景我们有一个网站(名称为test),它使用了一个应用程序池(名称也为test)这个应用程序池所使用的用户帐号为app_pool_test这个帐号当前的密码,假设为 abc 。当我设置好之后,我可...

重庆网站备案需要提供哪些资料?时间多久?

在如今这个互联网时代,任何行业的成长都路不开发达的网络。近些年经济水平的提升和综合实力的增强,带动了重庆网站建设行业的成长,越来越多的公司都着手珍视起网站的价值来来。而要想让自己的网站被更多的人知晓,...

线上教育网站制作添加哪些新功能

线上教育成为当下受欢迎的教育模式,那线上教育应该添加哪些新功能来吸引更多的用户并为用户提供更便捷的服务呢? 1.在线交流的功能 线上教育不能实现面对面的交流,而通过视频、语音、聊天...

重启IIS提示"不支持此接口"这个错误,无法正常重启的解决方法

最近本机调试程序,重启IIS老提示"不支持此接口"这个错误,无法正常重启,日志里也没错误,我用的是win 2003 的系统,经过搜索(搜索引擎是个好东西)发现是360最新版,也就是...

那些免备案网站所存在的劣势

哪些网站是不需要做备案的呢?凡是使用国外服务器的网站都是可以不做备案的。不参与备案确实会变得简单许多,但是不备案所导致的问题也挺多的,我们继续往下看:通常国内企业做网站的服务对象都是国人,如果你使用国...