首页 > 解决方案 > Prestashop - 模块中的 index.php?controller=404

问题描述

我已经在 Prestashop Addons(PrestaShop 1.6)中发布了模块,它在我的本地环境以及生产环境中都可以正常工作,并且已经有几个客户安装了它。

我正在使用模块前端控制器在模块内部导航(在管理面板端使用友好链接,在 vue.js 中构建 UI),例如 domain.com/mymodulename/login、domain.com/mymodulename/logout 等...

但是有一个客户的平台(打开友好链接),我的模块正在访问上面提到的任何请求的 url,但立即被重定向到 domain.com/lang/index.php?controller=404,状态为 404。

我无法在我的本地环境中重现该问题 - 下面的 htaccess 文件:

SetEnv HTTP_MOD_REWRITE On

RewriteEngine on

#Domain: presta.platformname.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %

{ENV:REWRITEBASE}
webservice/dispatcher.php?url=$1 [QSA,L]

Images
RewriteRule ^([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ % {ENV:REWRITEBASE}
img/p/$1/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9])?/.\.jpg$ %

{ENV:REWRITEBASE}
img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteRule ^c/([0-9])(-[\.*_a-zA-Z0-9-]*)(-[0-9])?/.+\.jpg$ %

{ENV:REWRITEBASE}
img/c/$1$2$3.jpg [L]
RewriteRule ^c/([a-zA-Z_-])(-[0-9])?/.+\.jpg$ %

{ENV:REWRITEBASE}
img/c/$1$2.jpg [L]

AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
Dispatcher
RewriteCond % {REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME}
-l [OR]
RewriteCond %

{REQUEST_FILENAME}
-d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %

{ENV:REWRITEBASE}
index.php [NC,L]

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/font-woff .woff
AddType font/woff2 .woff2

Header set Access-Control-Allow-Origin "*"

#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

标签: phpredirectmoduleprestashop

解决方案


推荐阅读