先说说情况: 1、开启ecstore伪静态的两个步骤: (1)在nginx里server部分添加: 1 2 3 4 location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; } (2)修改程序的config.php文件,把下面这行

先说说情况:

1、开启ecstore伪静态的两个步骤:

  (1)在Nginx里server部分添加:

1 2 3 4 location / {     if (!-e $request_filename) {         rewrite ^/(.*)$ /index.php/$1 last;     }

(2)修改程序的config.php文件,把下面这行

1 define('WITH_REWRITE',false);

  改成

1 define('WITH_REWRITE',true);

 

开启后,网址里的index.php就没有了,比如https://www.zhiu.cn/index.php/product-75.html就变成了:https://www.zhiu.cn/product-75.html ,url友好多了。

 

2、会出现什么问题?

  登陆后台后,通过这个地址:https://www.zhiu.cn/index.php/shopadmin 登陆后台成功后,会跳转到 https://www.zhiu.cn/shopadmin/ 这个地址,但这个地址是不存在的,所以就提示:

Nginx下ecstore伪静态开启后的后台跳转问题  Nginx ecstore 伪静态 第1张

测试环境下这样无所谓,但在给客户布署交付时,就会出现如下提示:

 

Nginx下ecstore伪静态开启后的后台跳转问题  Nginx ecstore 伪静态 第2张

  因为商派限制了必须通过 https://www.zhiu.cn/index.php/shopadmin这样的地址访问后台,否则授权就失败(很变态的限制呀)。

 

3、如何解决这个bug?

  我的这个办法也有点变态(^o^),既然提示找不到https://www.zhiu.cn/shopadmin,那我就在根目录下建一个shopadmin目录,然后往里面放一个index.php文件,文件内容如下:

 

1 2 3 4 5 6 < ?  php //重定向浏览器 header("Location:https://www.zhiu.cn/index.php/shopadmin/index.php"); //确保重定向后,后续代码不会被执行  exit; ? >

 

 懂代码的一看就明白了,它实际不过是一个地址跳转而以,把地址再跳转回正确的地址上去。

 

 

 

 

===========================================================================================================

 

以上都是浮云,最完美的解决办法来了:

 

在nginx中使用下面这个规则,啥问题都浮云了,让那些看文章只看一半的人去折腾去吧,哈哈~_~  。

 

1 2 3 4 5 6 7 8 9 10 location / {     if (!-e $request_filename) {       rewrite ^/(.*)$ /index.php/$1 last;     }     index index.php index.htm index.html; } location ~ ^/shopadmin {     rewrite  ^/(.*)$  /index.php/$1 last;     break; }  

转载请说明出处
知优网 » Nginx下ecstore伪静态开启后的后台跳转问题

发表评论

您需要后才能发表评论