当前位置:首页>正文

Nginx伪静态规则怎么设置 thinkphp 伪静态 nginx 规则怎么设置

2023-05-18 17:25:31 互联网 未知

Nginx伪静态规则怎么设置

1、输入以下命令
cd /alidata/server/nginx/conf/rewrite再输入ll
看看是不是像下面截图的一样。
2、这些就是伪静态规则文件。我们打开phpwind.conf看看。
已经在rewrtie目录下配置了常见程序的伪静态规则。可以直接调用。
3、如果没有就按照程序名.conf的命名方式新建一个配置文件
配置文件搞清楚了,你可能会说好像网站伪静态还是没效果啊。别着急,因为伪静态规则是需要被网站配置文件调用才行的。
4、输入以下命令
cd /alidata/server/nginx/conf/vhosts
进入到网站配置目录
5、打开配置文件
修改好伪静态调用文件
下面测试下我们配置的文件是否正确吧输入
nginx: the configuration file /alidata/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /alidata/server/nginx/conf/nginx.conf test is successful
如果出现以上两句话就说明配置成功了。下面重启下nginx就可以了。

thinkphp 伪静态 nginx 规则怎么设置

关于nginx的伪静态设置(案例)
server {
listen 80
server_name localhost
index index.html index.htm index.php
root /alidata/www/
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last
}
}
location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock
fastcgi_pass 127.0.0.1:9000
fastcgi_index index.php
include fastcgi.conf
# 以下是为了让Nginx支持PATH_INFO
set $path_info ""
set $real_script_name $fastcgi_script_name
if ($fastcgi_script_name ~ "^(. ?.php)(/. )$") {
set $real_script_name $1
set $path_info $2
}
fastcgi_param script_FILENAME $document_root$real_script_name
fastcgi_param script_NAME $real_script_name
fastcgi_param PATH_INFO $path_info
fastcgi_connect_timeout 120
fastcgi_send_timeout 120
fastcgi_read_timeout 120
fastcgi_buffers 8 128K
fastcgi_buffer_size 128K
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d
}
location ~ .*.(js|css)?$
{
expires 1h
}
#伪静态规则
access_log /alidata/log/nginx/access/default.log
}

nginx怎样设置伪静态规则 thinkphp

网站根目录建 nginx.htaccess 文件

rewrite "^(.*?).htaccess$" /404.html last
if (!-e $request_filename){
##Delphi
rewrite "^/test.html(|/)$" /index.php last//照着这条写就是
}

如何配置nginx伪静态以支持ThinkPHP的PATHINFO模式

在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last
break
}
}
注意if和括号之间的空格