方维整站系统伪静态实现

 方维整站系统伪静态实现
默认给的文件是.htassess
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.50
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

启用后无法访问,查看错误日志,有如下内容,

Apache错误日志
[Thu Apr 22 15:34:57 2010] [error] [client 123.122.83.2] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that Re
writeRule directive is forbidden: /var/www/website/admin.php

在apache配置文件或虚拟主机网站目录下.htaccess文件中修改或增加如下Options选项
Options +FollowSymLinks
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.50
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

说明:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
以上两条是apache的rewrite规则的条件配置,
“RewriteCond指令定义了规则生效的条件,即在一个RewriteRule指令之前可以有一个或多个RewriteCond指令。条件之后的重写规则仅在当前URI与Pattern匹配并且满足此处的条件(TestString能够与CondPattern匹配)时才会起作用。”
!-d  说明“REQUEST_FILENAME”如果不是目录,则匹配
!-f   说明”REQUEST_FILENAME“如果不是文件,则匹配
匹配成功后则rewrite到index.php

QSA说明:   Query   String   Append  
   
  This   flag   forces   the   rewriting   engine   to   append   a   query   string   part   in   the   substitution   string   to   the   existing   one   instead   of   replacing   it.   Use   this   when   you   want   to   add   more   data   to   the   query   string   via   a   rewrite   rule.

发表回复

您的电子邮箱地址不会被公开。