Zend framework2 Zend Framework 2 Htaccess
大家好,我在ZF2中遇到htaccess问题 我创建vhost,所有的工作都很好。当我打电话时 我的vhost.localhost都能正常工作,但当我添加一些uri段,如/index.php或/1234时 我得到404 我在public dir中编辑.htaccess并将Zend framework2 Zend Framework 2 Htaccess,zend-framework2,Zend Framework2,大家好,我在ZF2中遇到htaccess问题 我创建vhost,所有的工作都很好。当我打电话时 我的vhost.localhost都能正常工作,但当我添加一些uri段,如/index.php或/1234时 我得到404 我在public dir中编辑.htaccess并将 RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.*$ index.php [NC,L] 但是我又有404。你知道我怎么才能让它慢下来吗 我的完全访问权限是: Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ index.php [NC,L]
但是我又有404。你知道我怎么才能让它慢下来吗
我的完全访问权限是:
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
ServerName zf2-tutorial.localhost
DocumentRoot/var/www/html/zf2 tutorial/public
SetEnv应用程序_ENV“开发”
DirectoryIndex.php
允许超越所有
命令允许,拒绝
通融
谁认为问题是路由检查我的路由模块
<?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',
),
),
);
附带的.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_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
它与您的副本略有不同,我在一个工作示例中尝试了您的.htaccess文件,它看起来很好
您看到的404是通用的“服务器外观”404还是ZF2主题页面
可能是个愚蠢的建议,但你试过了吗
据我所知,您不应该直接调用.php文件附带的.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_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
它与您的副本略有不同,我在一个工作示例中尝试了您的.htaccess文件,它看起来很好
您看到的404是通用的“服务器外观”404还是ZF2主题页面
可能是个愚蠢的建议,但你试过了吗
据我所知,你不应该直接调用.php文件我不确定现在回答这个问题是否为时已晚,Finbarr建议你试试
或者
每次我输入www.zf2-tutorial.loc时都会遇到同样的问题,它总是被重定向到xampp主页
最后我读了我改成的froom Finbarr的评论
http://www.zf2-tutorial.loc/zf2-tutorial/public/
之后,加载了网页:WelcometoZendFramework2
#the virtual host:
名称虚拟主机*:80
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
<DocumentRoot "C:/xampp/htdocs/zf2-tutorial/public"
ServerName www.zf2-tutorial.loc zf2-tutorial.loc
ServerAlias zf2-tutorial.loc
<Directory "C:/xampp/htdocs/zf2-tutorial/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
apache(httpd conf)具有以下设置一些人建议删除哈希标记,但我没有为自己工作,所以将其保留为我发现的:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
同样在同一个文件(httpd conf)中,我将AllowOverride None更改为AllowOverride FileInfo,如下所示:
<Directory />
AllowOverride FileInfo
Require all denied
</Directory>
AllowOverride文件信息
要求全部拒绝
重新启动xampp并显示在祝贺网页上 我不确定现在回答这个问题是否为时已晚,芬巴尔建议我们试试
或者
每次我输入www.zf2-tutorial.loc时都会遇到同样的问题,它总是被重定向到xampp主页
最后我读了我改成的froom Finbarr的评论
http://www.zf2-tutorial.loc/zf2-tutorial/public/
之后,加载了网页:WelcometoZendFramework2
#the virtual host:
名称虚拟主机*:80
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
<DocumentRoot "C:/xampp/htdocs/zf2-tutorial/public"
ServerName www.zf2-tutorial.loc zf2-tutorial.loc
ServerAlias zf2-tutorial.loc
<Directory "C:/xampp/htdocs/zf2-tutorial/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
apache(httpd conf)具有以下设置一些人建议删除哈希标记,但我没有为自己工作,所以将其保留为我发现的:
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
同样在同一个文件(httpd conf)中,我将AllowOverride None更改为AllowOverride FileInfo,如下所示:
<Directory />
AllowOverride FileInfo
Require all denied
</Directory>
AllowOverride文件信息
要求全部拒绝
重新启动xampp并显示在祝贺网页上 你知道ZF2路由吗?这不是路由,这是HTACCESS阅读相册教程,如果可以,也请发布vhost文件。可能是AllowOverride设置为none(在这种情况下,永远不会执行.htaccess),或者您指向了错误的文件夹?您提供的vhost文件部分工作正常。也许正如@noobie php所暗示的,这可能是一个路由问题。或者模块配置?你知道ZF2路由吗?这不是路由,这是HTACCESS阅读相册教程。如果可以,也请发布vhost文件。可能是AllowOverride设置为none(在这种情况下,永远不会执行.htaccess),或者您指向了错误的文件夹?您提供的vhost文件部分工作正常。也许正如@noobie php所暗示的,这可能是一个路由问题。还是模块配置?