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

admin3年前网站建设34

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

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

相关文章

一篇好的文章如何规划网站描述让搜索引擎抓取

一篇好的文章如何规划网站描述让搜索引擎抓取,对于网站优化者来说大家都知道网站的三大标签很重要,这是为什么呢?下面网站建设小编张工用细节来告诉你网站描述的重要性。  网站内容如何能在万千结果中得到展现,...

网站改版也叫网站升级达到什么样的条件需要改版网站

周所众知网站改版就是对之前的网上做升级改造,随着时间的发展互联网技术日新月异,更快的网速,更清晰的分辨率,更合理的网站布局和更能打动当下消费者的网站效果和文案,让网站升级改版已经成为了企业不得不去做的...

什么才是网站建设运营?主要分为5大部分

什么才是网站建设运营?主要分为5大部分,网站建设公司所谓的网站运营其实说白了即是本来即是把那个东西或许你的商品通过各种不一样的方法结合运作,让它正常工作起来而已。百度百科是这么解说运营的&ldq...

开发APP的一些流程,你知道吗

随着互联网的发展,手机已经变成人类生活的一部分了,从早晨起床到晚上睡觉前我们第一个接触的就是手机。清晨,闹钟APP叫我们起床,公交地铁APP伴我们上路,钉钉APP让我们无接触打卡,中午我们会打开外卖A...

网站运行慢的解决办法

在互联网时代,网站的运行速度是重要而紧急的问题,一个能够迅速响应用户需求、高效加载内容的网站,可以增加用户的好感度,提升用户留存率,甚至帮助企业实现商业利益的最大化,而如果网站运行缓慢,就会导致用户流...

做好网站制作的四大要素我们一定要明白

随着互联网时代的发展,网站建设对于一个企业来说也变得越来越重要。网站定位是否明确、结构是否清晰、视觉冲击力是否强、产品的展示力和销售力是否强,包括公信力、传播力度等等,都是影响企业宣传的重要因素。网站...