一聚教程网:一个值得你收藏的教程网站

热门教程

Windows2003服务器Apache伪静态设置步骤

时间:2022-06-30 17:55:37 编辑:袖梨 来源:一聚教程网

1.检测Apache是否支持mod_rewrite

通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,

其中列出了所有apache2handler已经开启的模块,如果里面包括“mod_rewrite”,则已经支持,不再需要继续设置。

如果没有开启“mod_rewrite”,则打开目录 您的apache安装目录“/apache/conf/” 下的 httpd.conf 文件,
通过Ctrl+F查找到“LoadModule rewrite_module”,将前面的”#”号删除即可。

如果没有查找到,则到“LoadModule” 区域,在最后一行加入


“LoadModule rewrite_module modules/mod_rewrite.so”(必选独占一行),

然后重启apache服务器即可。

2.让apache服务器支持.htaccess

  修改httpd.conf文件
 
 

  里面的

  Options FollowSymLinks
  AllowOverride None

  改为

  Options FollowSymLinks
  AllowOverride All

下面是Discuz的伪静态设置文本:

# 将 RewriteEngine 模式打开
RewriteEngine On
# Rewrite 系统规则请勿修改
RewriteRule ^archiver/((fid|tid)-[0-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 ^space-(username|uid)-(.+).html$ space.php?$1=$2
RewriteRule ^tag-(.+).html$ tag.php?name=$1

以下是Phpwind的伪静态设置文本:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)simple/([a-z0-9_]+.html)$ $1/simple/index.php?$2

此外,还有很多种不同的规则,如果想制定出适用于自己站点的伪静态规则,必须熟悉网站结构和正则表达式

热门栏目