ThinkPHP6项目基操(2.Nginx配置虚拟域名及简化访问路径)
生活随笔
收集整理的這篇文章主要介紹了
ThinkPHP6项目基操(2.Nginx配置虚拟域名及简化访问路径)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Nginx配置虛擬域名及隱藏public和index.php路徑
- 一、phpStudy 創(chuàng)建網(wǎng)站
- 二、隱藏index.php
- 方法一:vhosts.conf
- 方法二:phpStudy面板配置偽靜態(tài)
- 方法三:工程根目錄添加 `nginx.htaccess` 文件
一、phpStudy 創(chuàng)建網(wǎng)站
(index/test是寫在index控制器下的test方法)
二、隱藏index.php
如果希望隱藏index.php,直接訪問(wèn) http://tp6.com/index/test需要再配置Nginx服務(wù)器:
方法一:vhosts.conf
點(diǎn)擊剛新建的網(wǎng)站的vhosts.conf配置文件,添加代碼:
完整的文件:
server {listen 80;server_name tp6.com;root "D:/phpstudy_pro/WWW/tp6/public";location / {index index.php index.html error/index.html;if (!-e $request_filename){ rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^/(.*)$ /index.php?s=$1 last; }error_page 400 /error/400.html;error_page 403 /error/403.html;error_page 404 /error/404.html;error_page 500 /error/500.html;error_page 501 /error/501.html;error_page 502 /error/502.html;error_page 503 /error/503.html;error_page 504 /error/504.html;error_page 505 /error/505.html;error_page 506 /error/506.html;error_page 507 /error/507.html;error_page 509 /error/509.html;error_page 510 /error/510.html;include D:/phpstudy_pro/WWW/tp6/public/nginx.htaccess;autoindex off;}location ~ \.php(.*)$ {fastcgi_pass 127.0.0.1:9004;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;} }如果不是使用集成環(huán)境,可以將上面的代碼復(fù)制到Nginx相關(guān)配置文件中。
配置完成,重啟Nginx服務(wù)器。
現(xiàn)在下面兩種方式都可以訪問(wèn)了:
http://tp6.com/index/test
http://tp6.com/index.php/index/test
方法二:phpStudy面板配置偽靜態(tài)
網(wǎng)站列表 > 管理 > 修改 > 偽靜態(tài) 添加以下代碼:
方法三:工程根目錄添加 nginx.htaccess 文件
添加代碼:
if (!-e $request_filename){ rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^/(.*)$ /index.php?s=$1 last; }??重磅推薦:免費(fèi)商用電商系統(tǒng)
😏想白嫖整個(gè)電商系統(tǒng)用來(lái)商用?
🤑想有自己的商城實(shí)現(xiàn)財(cái)富自由?
🤓想學(xué)習(xí)最佳實(shí)踐提升自己技術(shù)?
快來(lái)進(jìn)入🚀 傳送門 🚀,開(kāi)源免費(fèi)、完整示例帶你快速入門,輕松二開(kāi),走上人生巔峰!👨?🎓
總結(jié)
以上是生活随笔為你收集整理的ThinkPHP6项目基操(2.Nginx配置虚拟域名及简化访问路径)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 十大常用个人linux,Linux—常用
- 下一篇: python交流群教学视频_自学 Pyt