ThinkPHP3.2 偽靜態配置


 

前台偽靜態且隱藏入口文件 就把“.htaccess文件” 放到指定文件夾下面 如圖home做偽靜態並隱藏入口文件:

 


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM