Discuz!X在Apache环境下的.htaccess文件配置
- # 以下文件若没有可以忽略
- # 网站外链跳转文件URL重写
- RewriteRule ^goto/(.*)$ /go.html?url=$1 [L]
- # 网站地图文件URL重写
- #RewriteRule ^(sitemap)\.xml$ $1.php
- #RewriteRule ^(baiduxml)\.xml$ $1.php
- #RewriteRule ^(txtmap)\.txt$ $1.php
- # 开启HTTPS则启用,否则请注释下面四行规则
- RewriteEngine on
- RewriteBase /
- RewriteCond %{SERVER_PORT} !^443$
- RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
- # 禁止被框架
- SetEnvIf Request_URI "/favicon.ico" allow_framing=true
- Header set X-Frame-Options SAMEORIGIN env=!allow_framing
- # 防盗链(图片类)
- RewriteEngine on
- # 允许直接访问
- RewriteCond %{HTTP_REFERER} !^$ [NC]
- # 允许域名
- RewriteCond %{HTTP_REFERER} !docnn.cn [NC]
- # 允许的搜索引擎域名
- RewriteCond %{HTTP_REFERER} !google.com [NC]
- RewriteCond %{HTTP_REFERER} !google.com.hk [NC]
- RewriteCond %{HTTP_REFERER} !baidu.com [NC]
- RewriteCond %{HTTP_REFERER} !so.com [NC]
- RewriteCond %{HTTP_REFERER} !sogou.com [NC]
- RewriteCond %{HTTP_REFERER} !bing.com [NC]
- RewriteCond %{HTTP_REFERER} !cache.baiducontent.com [NC]
- RewriteCond %{HTTP_REFERER} !webcache.googleusercontent.com [NC]
- RewriteCond %{HTTP_REFERER} !cncc.bingj.com [NC]
- RewriteCond %{HTTP_REFERER} !snapshot.sogoucdn.com [NC]
- RewriteCond %{HTTP_REFERER} !c.360webcache.com [NC]
- # 防盗链替代图片
- RewriteRule .*\.(gif|jpg|png|bmp|ico|svg)$ https://www.baidu.com/img/baidu_jgylogo3.gif [R,NC,L]
- # 压缩文件
- <IfModule mod_deflate.c>
- # 强制 compression for mangled headers.
- # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
- <IfModule mod_setenvif.c>
- <IfModule mod_headers.c>
- SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
- RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
- </IfModule>
- </IfModule>
- # Compress all output labeled with one of the following MIME-types
- # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
- # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
- # as `AddOutputFilterByType` is still in the core directives).
- <IfModule mod_filter.c>
- AddOutputFilterByType DEFLATE application/atom+xml \
- application/javascript \
- application/json \
- application/rss+xml \
- application/vnd.ms-fontobject \
- application/x-font-ttf \
- application/x-web-app-manifest+json \
- application/xhtml+xml \
- application/xml \
- font/opentype \
- image/svg+xml \
- image/x-icon \
- text/css \
- text/html \
- text/plain \
- text/x-component \
- text/xml
- </IfModule>
- </IfModule>
- # 支持WebP图片格式
- RewriteEngine On
- RewriteCond %{HTTP_ACCEPT} image/webp
- RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
- RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
- # 禁止IE兼容视图
- <IfModule mod_headers.c>
- BrowserMatch MSIE is-msie
- Header set X-UA-Compatible IE=edge env=is-msie
- </IfModule>
- #阻止下载
- <FilesMatch "\.(tex|log|aux|pdf)$">
- Header set Content-Type text/plain
- </FilesMatch>
- Options -Indexes
- # 设置首页,越靠前优先级越高
- DirectoryIndex portal.php forum.php index.php
- <Files ~ "^.(htaccess|htpasswd)$">
- deny from all
- </Files>
- # 置错误页
- ErrorDocument 404 /404.html
- order deny,allow
- # 将 RewriteEngine 模式打开
- RewriteEngine On
- # 修改以下语句中的 /discuz 为您的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
- RewriteBase /
- # Rewrite 系统规则请勿修改
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- RewriteRule ^(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1
- RewriteCond %{QUERY_STRING} ^(.*)$
- 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”站点无关!
2. 本站的所有资源为购买、网络收集,或者用户投稿的资源,版权归原作者及网站所有!
3. 如若侵犯了您的权利,请及时联系站长删除!
4. 本站提供的资源,都不包含技术服务请大家谅解!
5. 此软件“仅限学习交流,不能用于商业用途”!
6. 如用于商业用途,请到官方购买正版软件,追究法律责任与“云墨SEO”站点无关!
- 我的微信
- 这是我的微信扫一扫
-
- 站长技术资源群
- QQ群:431710796
-
评论