我正在zend框架1.12中开发一个项目 要在index.php上重定向域,我使用了两个.htaccess,一个在root中,一个在公共文件夹中
我的问题是,当我输入域名时,它应该在索引控制器上重定向。
文件夹结构如下
application
--configs
----application.ini
library
--Zend
public
--css
--js
--index.php
--.htaccess
.htaccess
以下是用root .htaccess文件写的
RewriteEngine on
RewriteRule (.*) public/$1
以下是用public / .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 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
应用/ CONFIGS /的application.ini
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.baseUrl = "/"
resources.session.remember_me_seconds = 864000
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "root123"
resources.db.params.dbname = "labs"
resources.db.isDefaultTableAdapter = true
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
resources.db.params.profiler.enabled = true
resources.db.params.profiler.class = Zend_Db_Profiler_Firebug
使用上述设置一切正常。但我无法在根目录中创建任何其他文件夹。 如果我创建名为abc的新文件夹并访问domain.com/abc,我无法访问。它将此视为控制器动作。
请帮助我如何解决这个问题。 为了解决这个问题,我尝试将index.php放在公共文件夹的根目录中。之后没有什么能正常工作。
答案 0 :(得分:1)
使用以下代码更新.htacces
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 ^images/(.*)$ public/images/$1 [L]
RewriteRule ^css/(.*)$ public/css/$1 [L]
RewriteRule ^.*$ index.php [NC,L]
答案 1 :(得分:0)
这是Zend的原则,它用于检索url(模块),控制器和动作
您可以尝试以不同方式为anayser网址设置routing
否则,如果要访问每个人都可以访问的文档,您可以将它们公开。
我希望它会有所帮助