1、域名配置
E:\projectAll\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
#项目根目录
DocumentRoot "E:\projectAll\wamp\www\fx"
//域名
ServerName www.fx.com
//错误日志按照日期生成日志文件
#ErrorLog "|bin/rotatelogs.exe -l E:/wamp/log/error/mos%Y_%m_%d_error.log 86400"
#CustomLog "|bin/rotatelogs.exe -l E:/wamp/log/access/mos%Y_%m_%d_access.log 86400" common
<Directory "E:\projectAll\wamp\www\fx">
#是否允许Rewrite
AllowOverride all
#如果没有默认页面的话,是否显示列表
#Options Indexes FollowSymLinks
Options FollowSymLinks INCLUDES IncludesNOEXEC
#设置访问权限
Order allow,deny
Allow from all
DirectoryIndex index.php
#php SSI
AddOutputFilter Includes .php
#ErrorDocument 404 /errorhtml/error.html
#ErrorDocument 403 /errorhtml/error.html
</Directory>
</VirtualHost>
2、apache URL伪静态配置(thinkephp为例)
A)http.conf配置文件中加载mod_rewrite.so模块
B)AllowOverride None将None改为All
C)把下面内容保存为.htaccess文件放到应用入口文件的同级目录下
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
D)将thinkPHP中config文件里,配置URL访问模式
'URL_MODEL'=> 2,// URL访问模式,可选参数0、1、2、3,代表以下四种模式:// 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE 模式); 3 (兼容模式) 默认为PATHINFO 模式
E)设置访问路径的后缀名'URL_HTML_SUFFIX'=>'html',//默认后缀名
F)设置完成,访问如下:
配置前访问路径:
http://serverName/index.php/模块/控制器/操作/[参数名/参数值...]
配置后访问路径:
http://serverName/模块/控制器/操作/[参数名/参数值...]
3、IIS配置伪静态(thinkPHP为例)
在url重写模块中,导入.htaccess文件规则即可,重启网站!!!
4、nginx下的配置
在nginx.conf server模块添加:
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
重启nginx