Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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
Zend framework .htaccess:如何重定向img,js。。从/www/到/www/public/?_Zend Framework_.htaccess_Redirect - Fatal编程技术网

Zend framework .htaccess:如何重定向img,js。。从/www/到/www/public/?

Zend framework .htaccess:如何重定向img,js。。从/www/到/www/public/?,zend-framework,.htaccess,redirect,Zend Framework,.htaccess,Redirect,我现在有zend framework htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ public/index.php [NC,L] 但我不知道如何重定向所有“链接”参数,如j

我现在有zend framework htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]

但我不知道如何重定向所有“链接”参数,如js、css、img。

解决方案一: 您的web服务器应该指向public/directory,而不是ZF项目的根目录

解决方案二(我认为更好): 您的web服务器指向ZF项目目录,甚至ZF项目也位于子目录中。 喜欢

zf项目目录中的.htaccess(就在public/、application/、library/…附近):

.htaccess在public/directory中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
在application/configs/application.ini中设置

resources.frontController.baseUrl = "/zf-project/"

这是我的.htaccess,它的工作非常完美:

DirectoryIndex /public/index.php     
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^js/(.*)$     public/js/$1 [L]
RewriteRule ^img/(.*)$     public/img/$1 [L]
RewriteRule ^css/(.*)$     public/css/$1 [L]
RewriteRule ^.*$ public/index.php  [NC,L]

泽布卡,非常感谢!不幸的是,他们没有足够的声誉来给人留下一些印象:(
DirectoryIndex /public/index.php     
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^js/(.*)$     public/js/$1 [L]
RewriteRule ^img/(.*)$     public/img/$1 [L]
RewriteRule ^css/(.*)$     public/css/$1 [L]
RewriteRule ^.*$ public/index.php  [NC,L]