当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Access cgi-bin on cakePHP 3 folder

问题描述:

I'm making a cakePHP 3 app in which I need to have access to a cgi file in the cgi-bin folder directly. So if I type www.mysite.com/cgi-bin/myfile.cgi I should be able to see the output. The problem I'm having is with the routing, which obviously does not let me access it and instead it asks for the CgiBin controller. I know there is a way using rewrite rules, but I haven't been able to figure it out. I've tried putting the cgi-bin folder in the webroot folder and when I type www.mysite.com/cgi-bin/ I can see the folder index, but when I type www.mysite.com/cgi-bin/myfile.cgi it shows the missing controller error.

What can I do?

Thanks

网友答案:

cakephp 3 folder/ file structure + cgi

/www
 /bin/
 /cgi-bin/ <-----------------
 /logs/
 ...
 /webroot/
 .htaccess <------------ edit this file

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^cgi-bin$    cgi-bin/    [L]
    RewriteRule    ^cgi-bin/(.*) cgi-bin/$1    [L]
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>
分享给朋友:
您可能感兴趣的文章:
随机阅读: