Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 子目录/Url路由的ZF2重写_Apache_.htaccess_Url Rewriting_Zend Framework2 - Fatal编程技术网

Apache 子目录/Url路由的ZF2重写

Apache 子目录/Url路由的ZF2重写,apache,.htaccess,url-rewriting,zend-framework2,Apache,.htaccess,Url Rewriting,Zend Framework2,我的公用文件夹位于子目录中。所以我使用了两个.htaccess文件 公用文件夹目录之外的第一个目录是: RewriteEngine On RewriteRule ^(.*)$ public/$1 [NC,QSA] 公用文件夹中的第二个文件夹是默认的Zend文件夹: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUE

我的公用文件夹位于子目录中。所以我使用了两个.htaccess文件

公用文件夹目录之外的第一个目录是:

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [NC,QSA]
公用文件夹中的第二个文件夹是默认的Zend文件夹:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
当我转到时,会出现以下错误:

发生404错误

找不到页面

路由无法匹配请求的URL

,但当我去看电影时,这当然有效


我不确定是否需要修复.htaccess,或者是否需要修复路由

我认为最简单的解决方案是将公用文件夹的内容移动到其父目录

抄袭

确保将
myappname/.htaccess
替换为默认的zf2
public/.htaccess

然后在
myappname/index.php
中注释掉:

//chdir(dirname(__DIR__));
myappname/css
myappname/images
myappname/js
myappname/index.php
myappname/.htaccess
//chdir(dirname(__DIR__));