你好傢伙我在使用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