Php Zf2更改启动位置

Php Zf2更改启动位置,php,.htaccess,zend-framework2,Php,.htaccess,Zend Framework2,我的web服务器上有zf2,无法在Apache中更改启动位置。我将.htaccess复制到public_html,并在/public/index.php上更改了路径,但在CSS样式和js方面存在问题。我能在.htaccess中无误地完成吗 .htaccess: RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCon

我的web服务器上有zf2,无法在Apache中更改启动位置。我将.htaccess复制到public_html,并在/public/index.php上更改了路径,但在CSS样式和js方面存在问题。我能在.htaccess中无误地完成吗

.htaccess:

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting or installed the project in a subdirectory,
# the base path will be prepended to allow proper resolution of
# the index.php file; it will work in non-aliased environments
# as well, providing a safe, one-size fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}/public/index.php [L]

如果您在本地开发环境中,您根本不需要更改
.htaccess
,如果您像@bartek_zet所说的那样创建一个虚拟主机

因此,请使用默认的
.htaccess
文件,创建一个如下所示的虚拟主机:

# usually stored in /etc/apache/site-enabled/my-application.conf
<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /path/to/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /path/to/zf2-tutorial/public>
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
</VirtualHost>
#通常存储在/etc/apache/site enabled/my-application.conf中
ServerName zf2-tutorial.localhost
DocumentRoot/path/to/zf2 tutorial/public
SetEnv应用程序_ENV“开发”
DirectoryIndex.php
允许超越所有
命令允许,拒绝
通融

有关详细信息,请参见。

能否显示您的.htaccess?帖子已编辑,您有什么问题?你能说得更准确些吗?@bartek_zet它显示了站点索引和所有文件。虚拟主机设置可能有问题。在正常的托管中,我无法编辑Apache文件,但我使用了.htaccess,效果很好。谢谢