ThinkPHP3.2 伪静态配置

时间:2023-03-08 19:40:59
ThinkPHP3.2 伪静态配置
前台伪静态且隐藏入口文件 就把“.htaccess文件” 放到指定文件夹下面 如图home做伪静态并隐藏入口文件:

ThinkPHP3.2 伪静态配置
Apache为例,需要在入口文件的同级添加.htaccess文件
如果用的phpstudy:

1: <IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
// index.php 是当前的入口文件 这里写的是隐藏当前文件夹下的入口文件(隐藏项目的入口文件 找对路劲 隐藏 就对了)
</IfModule>
{如果index.php文件存放在public中,规则如下:
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ public/index.php [L,E=PATH_INFO:$1]
</IfModule>} 2: config的配置文件加如下几点:
'URL_MODEL'=>2, //模式
'URL_HTML_SUFFIX' => '.html', // 后缀
'URL_DENY_SUFFIX' => 'pdf|ico|png|gif|jpg|gif', // URL禁止访问的后缀设置
'URL_ROUTER_ON' => true, //开启路由
'URL_ROUTE_RULES' => array(
'index'=>'Index/index',
), 3: 但是访问方式必须是用 U函数
Httpd文件 第二个 修改成如下:
<Directory "F:/GZJ/phpstudy/sdystar/Apache/cgi-bin">
AllowOverride All
Options None
Require all granted
# RewriteEngine On
# RewriteRule ^(.*)\.htm$ $1.html
</Directory> Httpd.conf中必须开启(去掉前面的#)
LoadModule rewrite_module modules/mod_rewrite.so