【问题标题】:Set .htaccess for Zend Framework 1 on web server在 Web 服务器上为 Z​​end Framework 1 设置 .htaccess
【发布时间】:2015-10-07 00:09:05
【问题描述】:

这是我第一次尝试将一些项目放在网络服务器上。我真的不知道如何设置 Zend Framework 项目的 .htaccess 文件。

我有这个结构:

/webroot
    /ZendProject
        /application
        /docs
        /library
        /public
            /css
            /images
            /js
            .htaccess 
            index.php 
        /tests
    /include

这是我的默认 .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

感谢您的帮助

【问题讨论】:

  • 有什么问题?你想做什么 ?问题是什么?
  • 我需要向公共文件夹中的 index.php 发送任何请求
  • 那你有什么问题?您当前的 .htaccess 应该可以完成这项工作。
  • 如果我尝试www.webhost.it,它不会重定向到 index.php,但我会收到错误 403

标签: php apache .htaccess mod-rewrite zend-framework


【解决方案1】:

您的公共目录 .htaccess 应该是这样的

<IfModule rewrite_module>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} cron.php
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>

<IfModule !rewrite_module>
    DirectoryIndex alert.php
</IfModule>

如果您在无法控制 Apache 的地方托管您的项目,请将此 .htaccess 文件添加到您的项目根目录

RewriteEngine On
RewriteRule ^.*$ public/index.php [NC,L]
php_value magic_quotes 0
php_flag magic_quotes off
php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc off

【讨论】:

    猜你喜欢
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 1970-01-01
    相关资源
    最近更新 更多