Jump to content

8.偽靜態 rewrite


Jack

Recommended Posts

Posted (edited)

---------------------
偽靜態 rewrite
---------------------

建立偽靜態 rewrite 存放的目錄
mkdir -p /etc/nginx/rewrite

 


寫入ips論壇的偽靜態

vi /etc/nginx/rewrite/ips.conf

location / {
        try_files  $uri $uri/ /index.php;
  }

location ~^(/page/).*(.php)$ {
    try_files  $uri $uri/ /index.php;
}

location /api/ {
  if (!-e $request_filename){
    rewrite ^/api/(.*)$ /api/index.php;
  }
}

 

ESC儲存並離開
:wq

 

接下來,也需要修改配置檔  域名.com.conf

我放在這一行
include rewrite/ips.conf;
也就是
include rewrite/各種論壇的偽靜態.conf;

 

 

vi /etc/nginx/sites-available/域名.com.conf

搜尋
include rewrite

修改為
include rewrite/各種論壇的偽靜態.conf;

 


ESC儲存並離開
:wq

 

 

記得確認 各種論壇的偽靜態.conf 是否也有寫入
vi /etc/nginx/rewrite/各種論壇的偽靜態.conf

 

重新加载Nginx
nginx -t

nginx -s reload

 

有嚴重錯誤,將提示訊息

如果成功,則是以下的訊息

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

 

但不確定,如果只有偽靜態寫錯 (各種論壇的偽靜態.conf) 是否將提示?

 

Edited by Jack
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...