关于TP框架的开启路由重写功能

1.关于URL路由的重写 
  开启Apache 的F:\warmpsever\wamp\bin\apache\Apache2.4.4\conf   httpd.conf  中的mod_rewrite.so 模快  
(将前面的#去掉)    将 AllowOverride None 将None改为 All(文件中的内容)  在THinkPHP 的配置中 URL_MODEL设置为2
 <IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
  把下面的内容保存为.htaccess文件放到入口文件的同级目录下及 项目目录下
重启Apache之后,原来的
http://serverName/index.php/Blog/read/id/1
就可以通过访问
http://serverName/Blog/read/id/1
简化了URL地址。

猜你喜欢

转载自blog.csdn.net/qq_35786291/article/details/80944231
今日推荐