index.php?s=$1,thinkphp nginx配置rewrite,地址会多出个.php

thinkphp nginx配置rewrite,地址会多出个.php

,http://localhost:7080/.php?m=...

nginx配置文件

server

{

listen 80;

#listen [::]:80;

server_name localhost 192.168.150.79 doc.mall.com;

index index.html index.htm index.php default.html default.htm default.php;

root /data/www/wwwroot/mall_doc;

include none.conf;

#error_page 404 /404.html;

location / {

if (!-e $request_filename)

{

rewrite ^/index.php(.*)$ /index.php?s=$1 last;

rewrite ^(.*)$ /index.php?s=$1 last;

rewrite ^/(.*)$ /index.php/$1;

}

}

location ~ .php {

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fastcgi.conf;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

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;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}

access_log /data/www/wwwlogs/doc.mall.access_log;

}

rewrite ^/index.php(.*)$ /index.php?s=$1 last;

rewrite ^(.*)$ /index.php?s=$1 last;

rewrite ^/(.*)$ /index.php/$1;

这三种方式都试过了

'URL_MODEL' => 2,

php版本为PHP 7.1.5

nginx版本为:nginx/1.12.0

大家有么碰到这种情况?

php版本在5.6.9上是正常访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ThinkPHP 3.2.3中,可以通过修改.htaccess文件或者在Apache配置文件中增加重写规则来实现隐藏index.php和Home。 方法一:修改.htaccess文件 1. 首先,确认你的服务器支持.htaccess文件,并且.htaccess文件已经开启。 2. 在项目根目录下新建.htaccess文件,并添加以下内容: ``` RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] ``` 3. 保存并上传.htaccess文件到服务器根目录。 4. 修改配置文件config.php,将URL_MODEL参数改为2。 ``` 'URL_MODEL' => 2, ``` 5. 访问项目时,可以通过访问http://域名/控制器/方法 的方式来访问,而不需要在URL中加上index.php或Home。 方法二:在Apache配置文件中增加重写规则 1. 打开Apache配置文件httpd.conf,搜索LoadModule rewrite_module modules/mod_rewrite.so,并确保该模块已开启。 2. 在VirtualHost标签中添加以下内容: ``` <Directory "/var/www/html"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ``` 其中/var/www/html为项目根目录,AllowOverride All表示允许.htaccess文件中的重写规则生效。 3. 在.htaccess文件中添加以下内容: ``` RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] ``` 4. 修改配置文件config.php,将URL_MODEL参数改为2。 ``` 'URL_MODEL' => 2, ``` 5. 访问项目时,可以通过访问http://域名/控制器/方法 的方式来访问,而不需要在URL中加上index.php或Home。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值