Discuz!X在Apache环境下的.htaccess文件配置

云墨
云墨
云墨
647
文章
0
评论
2018年9月6日 评论 1,093

Discuz!X在Apache环境下的.htaccess文件配置

Discuz!X在Apache环境下的.htaccess文件配置

  1. # 以下文件若没有可以忽略
  2. # 网站外链跳转文件URL重写
  3. RewriteRule ^goto/(.*)$ /go.html?url=$1 [L]
  4. # 网站地图文件URL重写
  5. #RewriteRule ^(sitemap)\.xml$ $1.php
  6. #RewriteRule ^(baiduxml)\.xml$ $1.php
  7. #RewriteRule ^(txtmap)\.txt$ $1.php
  8. # 开启HTTPS则启用,否则请注释下面四行规则
  9. RewriteEngine on
  10. RewriteBase /
  11. RewriteCond %{SERVER_PORT} !^443$
  12. RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
  13. # 禁止被框架
  14. SetEnvIf Request_URI "/favicon.ico" allow_framing=true
  15. Header set X-Frame-Options SAMEORIGIN env=!allow_framing
  16. # 防盗链(图片类)
  17. RewriteEngine on
  18. # 允许直接访问
  19. RewriteCond %{HTTP_REFERER} !^$ [NC]
  20. # 允许域名
  21. RewriteCond %{HTTP_REFERER} !docnn.cn [NC]
  22. # 允许的搜索引擎域名
  23. RewriteCond %{HTTP_REFERER} !google.com [NC]
  24. RewriteCond %{HTTP_REFERER} !google.com.hk [NC]
  25. RewriteCond %{HTTP_REFERER} !baidu.com [NC]
  26. RewriteCond %{HTTP_REFERER} !so.com [NC]
  27. RewriteCond %{HTTP_REFERER} !sogou.com [NC]
  28. RewriteCond %{HTTP_REFERER} !bing.com [NC]
  29. RewriteCond %{HTTP_REFERER} !cache.baiducontent.com [NC]
  30. RewriteCond %{HTTP_REFERER} !webcache.googleusercontent.com [NC]
  31. RewriteCond %{HTTP_REFERER} !cncc.bingj.com [NC]
  32. RewriteCond %{HTTP_REFERER} !snapshot.sogoucdn.com [NC]
  33. RewriteCond %{HTTP_REFERER} !c.360webcache.com [NC]
  34. # 防盗链替代图片
  35. RewriteRule .*\.(gif|jpg|png|bmp|ico|svg)$ https://www.baidu.com/img/baidu_jgylogo3.gif [R,NC,L]
  36. # 压缩文件
  37. <IfModule mod_deflate.c>
  38.     # 强制 compression for mangled headers.
  39.     # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
  40.     <IfModule mod_setenvif.c>
  41.         <IfModule mod_headers.c>
  42.             SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  43.             RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  44.         </IfModule>
  45.     </IfModule>
  46.     # Compress all output labeled with one of the following MIME-types
  47.     # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
  48.     #  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
  49.     #  as `AddOutputFilterByType` is still in the core directives).
  50.     <IfModule mod_filter.c>
  51.         AddOutputFilterByType DEFLATE application/atom+xml \
  52.                                       application/javascript \
  53.                                       application/json \
  54.                                       application/rss+xml \
  55.                                       application/vnd.ms-fontobject \
  56.                                       application/x-font-ttf \
  57.                                       application/x-web-app-manifest+json \
  58.                                       application/xhtml+xml \
  59.                                       application/xml \
  60.                                       font/opentype \
  61.                                       image/svg+xml \
  62.                                       image/x-icon \
  63.                                       text/css \
  64.                                       text/html \
  65.                                       text/plain \
  66.                                       text/x-component \
  67.                                       text/xml
  68.     </IfModule>
  69. </IfModule>
  70. # 支持WebP图片格式
  71. RewriteEngine On
  72. RewriteCond %{HTTP_ACCEPT} image/webp
  73. RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
  74. RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
  75. # 禁止IE兼容视图
  76. <IfModule mod_headers.c>
  77.     BrowserMatch MSIE is-msie
  78.     Header set X-UA-Compatible IE=edge env=is-msie
  79. </IfModule>
  80. #阻止下载
  81. <FilesMatch "\.(tex|log|aux|pdf)$">
  82.     Header set Content-Type text/plain
  83. </FilesMatch>
  84. Options -Indexes
  85. # 设置首页,越靠前优先级越高
  86. DirectoryIndex portal.php forum.php index.php
  87. <Files ~ "^.(htaccess|htpasswd)$">
  88. deny from all
  89. </Files>
  90. # 置错误页
  91. ErrorDocument 404 /404.html
  92. order deny,allow
  93. # 将 RewriteEngine 模式打开
  94. RewriteEngine On
  95. # 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
  96. RewriteBase /
  97. # Rewrite 系统规则请勿修改
  98. RewriteCond %{QUERY_STRING} ^(.*)$
  99. RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
  100. RewriteCond %{QUERY_STRING} ^(.*)$
  101. RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
  102. RewriteCond %{QUERY_STRING} ^(.*)$
  103. RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
  104. RewriteCond %{QUERY_STRING} ^(.*)$
  105. RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
  106. RewriteCond %{QUERY_STRING} ^(.*)$
  107. RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
  108. RewriteCond %{QUERY_STRING} ^(.*)$
  109. RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
  110. RewriteCond %{QUERY_STRING} ^(.*)$
  111. RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
  112. RewriteCond %{QUERY_STRING} ^(.*)$
  113. RewriteRule ^(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
  114. RewriteCond %{QUERY_STRING} ^(.*)$
  115. RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1

 

 

1. 如有链接无法下载、失效或广告,请联系QQ:181289218 处理!
2. 本站的所有资源为购买、网络收集,或者用户投稿的资源,版权归原作者及网站所有!
3. 如若侵犯了您的权利,请及时联系站长删除!
4. 本站提供的资源,都不包含技术服务请大家谅解!
5. 此软件“仅限学习交流,不能用于商业用途”!
6. 如用于商业用途,请到官方购买正版软件,追究法律责任与“云墨SEO”站点无关!
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 站长技术资源群
  • QQ群:431710796
  • weinxin
云墨
  • 本文由 发表于 2018年9月6日
  • 转载请务必保留本文链接:https://www.yunmoseo.com/1658.html
匿名

发表评论

匿名网友