discuz apache伪静态(apache中伪静态配置和使用Apache虚拟主机下Discuz伪静态)
discuz apache伪静态
apache中伪静态配置和使用Apache虚拟主机下Discuz伪静态
一 打开 Apache 的配置文件 httpd.conf 。
二 将#LoadModule rewrite_module modules/mod_rewrite前面的#去掉
三 在 httpd.conf中添加:
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+\.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+)\.html$ $1.php?__is_apache_rewrite=1&__rewrite_arg=$2
</IfModule>
四 要实现asp帖子URL到php帖子的映射,在 第三步的<IfModule mod_rewrite.c>和</IfModule>之间添加:
RewriteMap tolowercase int:tolower
RewriteCond %{QUERY_STRING} (?:boardid|page|id|replyid|star|skin)\=\d+ [NC]
RewriteRule ^(.*(?:index|dispbbs))\.asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite=1
五 保存httpd.conf并重启Apache。
六、mod_rewrite 简介
Rewirte主要的功能就是实现URL的跳转和隐藏真实地址,基于Perl语言的正则表达式规范。平时帮助我们实现伪静态,拟目录,域名跳转,防止盗链等等
七、mod_rewrite 规则的使用
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.zzvips.com [NC]
RewriteRule ^/(.*) http://www.zzvips.com/ [L]
--------
RewriteEngine on
RewriteRule ^/test([0-9]*).html$ /test.php?id=$1
RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]
八、mod_rewrite 规则修正符
1) R 强制外部重定向
2) F 禁用URL,返回403HTTP状态码。
3) G 强制URL为GONE,返回410HTTP状态码。
4) P 强制使用代理转发。
5) L 表明当前规则是最后一条规则,停止分析以后规则的重写。
6) N 重新从第一条规则开始运行重写过程。
7) C 与下一条规则关联8) T=MIME-type(force MIME type) 强制MIME类型
9) NS 只用于不是内部子请求
10) NC 不区分大小写
11) QSA 追加请求字符串
12) NE 不在输出转义特殊字符 \%3d$1 等价于 =$1
Apache虚拟主机下使用Rewrite实现Discuz伪静态的配置
第一步 :当然是配置Apache支持Rewrite功能,这个不多说了,就是:
LoadModule rewrite_module modules/mod_rewrite.so
原来有注释的就去掉注释,原来没有的添加上。
上面的配置中:
1.Options FollowSymLinks 这一步的配置必须有。
2.AllowOverride all 原来None的要改成all。
这两个配置缺一不可。
第三步 ,大家就比较熟悉了也不多说了,
就是在对应的目录下面添加.htaccess文件,下面以discuz为例说明:
RewriteEngine On
RewriteBase /
RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
第四步 :配置Discuz使用伪静态:
登录后台管理,进入“全局”=》“优化配置”=》“搜索引擎优化”在原来URL静态化的地方选中,然后提交即可。
配置完毕,去discuz前台访问就可以了。原来的php都变成html了。
在apache配置文件中设置
复制代码 代码如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
RewriteRule ^/home/(space|network)-(.+)\.html$ /home/$1\.php\?rewrite=$2
RewriteRule ^/home/(space|network)\.html$ /home/$1\.php
RewriteRule ^/home/([0-9]+)$ /home/space\.php\?uid=$1
RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
</IfModule>
此文适用于Apache虚拟主机用户。
在开始以下设置之前,首先应该确认服务器支持mod_rewrite以及支持对站点目录中.htaccess的文件解析,否则即便按照下面的方法设置好了,也无法使用。点击查看Apache下开启mod_rewrite的方法。
Apache下开启mod_rewrite
服务器环境:Windows Server 2003 SP2 + Apache 2.0.59
开启方法:
用文本编辑器打开Apache安装目录\conf\httpd.conf,找到“#LoadModule rewrite_module modules/mod_rewrite.so”这行,去掉前面的“#”;继续查找“AllowOverride None”,修改为“AllowOverride All”;然后,重启Apache即可。
检查论坛所在目录中是否存在.htaccess 文件,如果不存在,则手工建立此文件。在Win32系统下,无法直接建立.htaccess 文件,则可以从其他系统中拷贝一份,也可以点击这里下载我做的一个,解压缩后即可使用。编辑并修改.htaccess文件,添加以下内容 :
复制代码 代码如下:
# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 /discuz 为你的论坛目录地址,如果程序放在根目录中,请将 /discuz 修改为 /
RewriteBase /discuz
# Rewrite 系统规则请勿修改
RewriteRule ^archiver/([a-z0-9\-]+\.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^profile-(username|uid)-(.+)\.html$ viewpro.php?$1=$2
添加内容时,请遵照上面的提示,修改论坛所在的路径,然后保存。将.htaccess文件上传到论坛所在的目录中。进入论坛系统设置,根据需要开启URL静态化功能。
-=======================================================
注意下面必须得
复制代码 代码如下:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@domain.com
DocumentRoot "E:\aaa\wwwroot"
ServerName *
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/archiver/([a-z0-9-]+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+).html$ $1/viewpro.php?$2=$3
RewriteRule ^ss-xs/([0-9]+)/spacelist(.*)$ /index.php?$1/action_spacelist$2
RewriteRule ^ss-xs/([0-9]+)/viewspace_(.+)$ /index.php?$1/action_viewspace_itemid_$2
RewriteRule ^ss-xs/([0-9]+)/viewbbs_(.+)$ /index.php?$1/action_viewbbs_tid_$2
RewriteRule ^ss-xs/([0-9]+)/(.*)$ /index.php?$1/$2
RewriteRule ^ss-xs/([0-9]+)$ /index.php?$1
RewriteRule ^ss-xs/action_(.+)$ /index.php?action_$1
RewriteRule ^ss-xs/category_(.+)$ /index.php?action_category_catid_$1
RewriteRule ^ss-xs/itemlist_(.+)$ /index.php?action_itemlist_catid_$1
RewriteRule ^ss-xs/viewnews_(.+)$ /index.php?action_viewnews_itemid_$1
RewriteRule ^ss-xs/viewthread_(.+)$ /index.php?action_viewthread_tid_$1
RewriteRule ^ss-xs/index([.a-zA-Z0-9]*)$ /index.php
</IfModule>
</VirtualHost>
=======================
复制代码 代码如下:
NameVirtualHost 124.129.183.146
<VirtualHost bbs.zzvips.com>
ServerName bbs.zzvips.com
DocumentRoot D:/WebSite/phpbbs
<Directory "D:/WebSite/phpbbs">
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/archiver/([a-z0-9-]+.html)$ $1/archiver/index.php?$2
RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3
RewriteRule ^(.*)/profile-(username|uid)-(.+).html$ $1/viewpro.php?$2=$3
RewriteRule ^ss-xs/([0-9]+)/spacelist(.*)$ /index.php?$1/action_spacelist$2
RewriteRule ^ss-xs/([0-9]+)/viewspace_(.+)$ /index.php?$1/action_viewspace_itemid_$2
RewriteRule ^ss-xs/([0-9]+)/viewbbs_(.+)$ /index.php?$1/action_viewbbs_tid_$2
RewriteRule ^ss-xs/([0-9]+)/(.*)$ /index.php?$1/$2
RewriteRule ^ss-xs/([0-9]+)$ /index.php?$1
RewriteRule ^ss-xs/action_(.+)$ /index.php?action_$1
RewriteRule ^ss-xs/category_(.+)$ /index.php?action_category_catid_$1
RewriteRule ^ss-xs/itemlist_(.+)$ /index.php?action_itemlist_catid_$1
RewriteRule ^ss-xs/viewnews_(.+)$ /index.php?action_viewnews_itemid_$1
RewriteRule ^ss-xs/viewthread_(.+)$ /index.php?action_viewthread_tid_$1
RewriteRule ^ss-xs/index([.a-zA-Z0-9]*)$ /index.php
</IfModule>
</VirtualHost>
- 开源asp.net(apache下支持asp.net的实现方法)
- apache安装与配置windows(Apache 安装和使用文档)
- apache实时框架(教你快速开启Apache SkyWalking的自监控)
- 怎么用apache自定义网站根目录(Apache 二级域名实现方法介绍)
- 做网站是使用nginx还是apache(web服务器软件Apache与Nginx的对比分析)
- apache服务部署tomcat(Apache与Tomcat服务器整合的基本配置方法及概要说明)
- 如何用wampserver打开自己写的php(WampServer下安装多个版本的PHP、mysql、apache图文教程)
- centos7 apache配置(CentOSLinux下的apache服务器配置与管理方法分享)
- apache 代理服务器返回403(Apache中301重定向的配置代码)
- apache服务配置详解(APACHE 多站点配置方法)
- apache配置讲解(apache中封IP的实现方法)
- apache服务配置详解(apache配置开启网站服务步骤)
- gzip指令配置参数用法(Gzip在apache2中的设置和squid对它的处理)
- 静态web服务器nginx(WEB服务器该选择 Apache 还是 Nginx?)
- win10怎么安装apache(apache启动失败怎么办 快速解决Win10系统apache启动失败的方法教程)
- dedecms标签调用原理(DEDECMS安全设置 执行php脚本限制设置方法apache+nginx)
- 白T恤穿法(白t恤)
- 你怎么忘了是说先爱我(你怎么忘了如何爱我)
- 做技术难吗(技术难不难)
- 林心如是谁(林心如是谁演的)
- 泰国安全吗(泰国安全吗2023)
- 菲律宾安全吗(菲律宾安全吗)
热门推荐
- ubuntu安装php(在Ubuntu 18.04上安装PHP 7.3 7.2和7.0的方法)
- thinkphp6.0安装(使用composer安装使用thinkphp6.0框架问题视频教程)
- mybatis 分页查询配置(mybatis-plus分页传入参数后sql where条件没有limit分页信息操作)
- mysql索引的弊端(MySQL 全文索引的原理与缺陷)
- dedecms使用教程(Dedecms提示信息及提示内容的修改方法)
- cookie政策及设置(详解操作cookie的原生方法cookieStore)
- python做出来的游戏按什么键运行(python pygame实现方向键控制小球)
- php列表怎么用(PHP开启目录引索+fancyindex漂亮目录浏览带搜索功能)
- php查找文件存在(php判断目录存在的简单方法)
- centos7离线安装mysql5.7(CentOS7.5 安装MySql的教程)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9