你好家伙我在使用htaccess的ZF2中遇到问题。Zend Framework 2 Htaccess
我创建了虚拟主机,所有的工作都很好。当我打电话
我-vhost.localhost所有的工作很好,但是当我添加一些URI段类似的index.php或/ 1234 我得到404
我编辑的.htaccess公开目录,并把
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [NC,L]
布尔再次我有404.任何想法我怎么能减慢这一点?
我的全是的.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 ^.*$ - [NC,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, 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_FILENAME} !-f
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
VHOST
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /var/www/html/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/html/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
谁想到的问题是路由检查我的路线国防部。
<?php
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/][:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
你有关于ZF2路线的想法? –
这不是路由这是HTACCESS READ ALBUM TUTORIAL – Ivan
如果可以,请发布您的vhost文件。它可能像AllowOverride设置为none(在这种情况下,.htaccess永远不会执行),或者您指向错误的文件夹? – Adrian