PHP 路由配置
2016-05-06 22:41
465 查看
一、Apache 的路由配置
1、Apache配置文件httpd.conf
修改目录重写
“AllowOverrideAll”,开启 Apache
模块rewrite_module(mod_rewrite.so)
2、Apache
虚拟主机Vhost开启,即开启 Apache
模块 alias_module(mod_vhost_alias.so),配置 httpd-vhosts.conf
在
系统盘/Windows/System32/drivers/etc
下的 hosts文件添加主机头
在 Apache/conf/extra
下修改 httpd-vhosts.conf
文件
<VirtualHost*:80>
ServerAdmin 1101202419@qq.com
DocumentRoot"C:\inetpub\wwwroot\phpweb"
ServerName
hostname
ErrorLog "logs/hostname-error.log"
CustomLog "logs/hostname-access.log" common
</VirtualHost>
3、确保URL_MODEL设置为2(ThinkPHP的配置)
4、把.htaccess文件放到入口文件的同级目录下,内容如下
<IfModulemod_rewrite.c>
RewriteEngineon
RewriteCond%{REQUEST_FILENAME} !-d
RewriteCond%{REQUEST_FILENAME} !-f
RewriteRule^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
二、IIS 路由配置
1、下载 URL Rewrite Module(64位版本为 rewrite_2.0_rtw_x64.msi ),安装应用程序即可支持 PHP 路由重写;2、应用程序配置web.config,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ThinkPHP" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- Apache Isis 1.4.0 发布,领域驱动开发框架
- PHP数据库长连接mysql_pconnect的细节
- RH436 Day3 课后总结
- Php Installing An Expansion
- Linux快速构建apache web服务器
- Awstats处理多apache日志
- 安装perl模块小窍门
- Apache静态编译与动态编译的区别
- php7 读取php.ini[4]
- IIS 错误 Server Application Error 详细解决方法
- webshell查看IIS站点配置的方法
- IIS运行错误 Server Application Error 错误代码 Error: 8004的解决方法
- PHP+Apache在Windows 9x下的安装和配置