thinkPHP 配置REWRITE URL模式

文章参考

1、httpd.conf配置文件中加载了mod_rewrite.so模块
LoadModule rewrite_module modules/mod_rewrite.so

2、httpd.conf配置文件中将None改为 All   
<Directory />
	Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

3、确保URL_MODEL设置为2
\Application\Common\Conf\config.php
<?php
return array(
	//'配置项'=>'配置值'
	'DEFAULT_MODULE'     => 'Web', //默认模块
    'URL_MODEL'          => '2', //URL模式
    'SESSION_AUTO_START' => true, //是否开启session
    
    //数据库配置
    'DB_TYPE'               =>  'mysql',     // 数据库类型
    'DB_HOST'               =>  'localhost', // 服务器地址
    'DB_NAME'               =>  'hms',          // 数据库名
    'DB_USER'               =>  'root',      // 用户名
    'DB_PWD'                =>  '',          // 密码
    'DB_PORT'               =>  '3306',        // 端口
    'DB_PREFIX'             =>  'hms_',    // 数据库表前缀
    
);


4、把下面的内容保存为.htaccess文件放到入口文件的同级目录下
<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>


5、重启apache





猜你喜欢

转载自blog.csdn.net/hbiao68/article/details/53173158
今日推荐