网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > 服务器环境搭建
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

服务器环境搭建 Windows,Linux,IIS,Apache等服务器配置、安全维护以及PHP和MYSQL运行环境讨论。

Reply
 
Thread Tools Display Modes
  #1   IP: 106.111.142.4
Old 2016-06-07, 11:52 AM
Deerwood Deerwood is offline
初级会员
 
Join Date: 2005-09-27
Posts: 1
Deerwood 现在声名狼藉
Default apache中伪静态配置和使用(Apache虚拟主机下Discuz伪静态)

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.cheapglasses.net [NC]
RewriteRule ^/(.*) http://www.cheapglasses.net/ [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了。
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:03 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.