Warning: mkdir(): No space left on device in /www/wwwroot/test001/func.php on line 253

Warning: file_put_contents(./cachefile_yuan/hillsideartistshouse.com/cache/8c/5422a/a6081.html): failed to open stream: No such file or directory in /www/wwwroot/test001/func.php on line 241
ThinkPHP框架的WEB係統隱藏index.php文件名大全_網站建設_網站製作_做網站的公司_999元全包_漢獅網絡

百姓彩票

先設計 後付費,服務更有保障

2024我們與您攜手共贏,為您的企業形象保駕護航!

ThinkPHP框架的WEB係統隱藏index.php文件名大全

技術人員大都使用過大名鼎鼎的ThinkPHP的程序框架,使用PHP語言開發的CMS係統中采用TP框架的占絕大多數。然而,對於新手來說直接上手開發整站係統還是有難度的,可以考慮先從一些成熟的基於TP框架的CMS係統開始著手學習。在係統中一般會采用偽靜態,那麽就會少不了路由規則,不熟悉正則表達式的同學有可能搞不定一些URL顯示問題,如:TP框架運行時默認路徑運行方式,會顯示index.php/路徑,不管哪個目錄都會包含index.php這個文件名,看起來不夠大氣,如何修改路由規則去掉這個文件名,就需要對.htaccess文件進行調整。

以Apache為例,需要在入口文件的同級添加.htaccess文件(官方默認自帶了該文件),內容如下:

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

如果用的phpstudy,規則如下:

<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] 
</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>

如果你使用的apache版本使用上麵的方式無法正常隱藏index.php,可以嚐試使用下麵的方式配置.htaccess文件:

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>

如果是Nginx環境的話,可以在Nginx.conf中添加:

locations / { // …..省略部分代碼
    if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
        break;
    }
}
vhosts-conf
server {
        listen       80;
        server_name  xhb.com www.xhb.com;
        root   "F:/project/xhb";
        locations / {
            index  index.html index.htm index.php;
            if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
        break;
    }
            #autoindex  on;
        }
        locations ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}



我漢獅網絡提供網站建設、APP軟件開發、軟件開發、小程序開發、網站網絡營銷等一站式服務,歡迎企業谘詢
免費谘詢:18838171308

先設計 後付費,服務更有保障

2024我們與您攜手共贏,為您的企業形象保駕護航!

在線客服
聯係方式

24h谘詢電話

18838171308

微信二維碼
微信