訪問某域名時,去掉index.php目錄時達到效果一樣 如:www.test1/index.php/test2跟www.test1/test2效果一致 在vhosts.conf中加重寫就可以了 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } eg: server { listen 80; server_name dev.pmp.com gohosts.com; root "D:\project\wanda"; index index.html index.htm index.php; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~ \.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; } } 如果遇到 修改后無法啟動nginx 那就是nginx組態檔中有特殊符號或漏掉符號. 建議用編輯器打開查看修改(!!!!一般用txt文本修改后經常出現特殊符號) ———————————————— #301重定向域名跳轉示例 域名先系結到主機然后修改對應域名去掉以下代碼前邊的#號即可生效 # if ($Host = 'xxx.com'){ # rewrite ^/(.*)$ http://www.xxx.com/$1 permanent; # } #discuz3.4偽靜態規則示例 請去掉以下代碼前邊的#號即可生效 # rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; # rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; # rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; # rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; # rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; # rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; # rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; # rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=https://www.cnblogs.com/roy1101/archive/2020/12/11/$3 last; # rewrite ^([^/.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_/-]+)/.html$ $1/plugin.php?id=$2:$3 last; # if (!-e $request_filename) { # return 404; # } #phpwind9.0偽靜態規則示例 請去掉以下代碼前邊的#號即可生效 # if (-f $request_filename) { # break; # } # if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") { # break; # } # if (!-e $request_filename) { # rewrite . /index.php last; # } #WordPress或ThinkPHP偽靜態規則示例 請去掉以下代碼前邊的#號即可生效 if (!-e $request_filename) { rewrite ^/(.*)$ /index.php$1 last; break; } #laravel偽靜態 location / {
try_files $uri $uri/ /index.php?$query_string;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/233487.html
標籤:其他
下一篇:js圖片滑動展示
