Zend 和 .htaccess [英] Zend and .htaccess

查看:29
本文介绍了Zend 和 .htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的默认zend"应用程序具有这种默认结构

My default 'zend' app has this default structure

/zend + webroot
    /application
    /config
    /library
    /public
        .htaccess
        index.php

默认的 .htaccess 通过 ./public/index.php 重定向各种控制器/动作细节

and the default .htaccess redirects the various controller/action details via ./public/index.php

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

我使用这个默认网址来访问应用

I use this default url to access the app

http://domain/index.php

我现在已转移到共享主机,其中 webroot 位于zend"根目录之上.

I've now moved to a shared host, where the webroot is above the 'zend' root.

/webroot
    /zend
        /application
        /config
        /public
            index.php
           .htaccess

但我只能通过这个网址访问我的应用

but i can only access my app via this URL

http://domain/zend/public/index.php

我希望能够使用

http://domain/zend/index.php

并进行 .htaccess 重定向.

and have .htaccess redirect.

我想知道如何调整 .htaccess 文件以重定向 URL 请求.我读这个教程,但我没有;不适合我

and i'm wondering how i can tweak the .htaccess file to redirect the URL requests. I read this tutorial but i didn;t work for me

/webroot
    /zend
        .htaccess
        /application
        /config
        /library
        /public
            index.php

这是本例中的 .htaccess 内容

This is the .htaccess content in this case

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

有人能发现什么吗?

推荐答案

创建包含此代码的 zend/index.php:

Create zend/index.php containing this code:

<?php include 'public/index.php';

现在创建包含此代码的 zend/.htaccess:

Now create zend/.htaccess containing this code:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteRule .* index.php

确保您的图像/css/js 文件都在 zend/public/中,并且不要删除 zend/public/.htaccess 文件:)

Make sure that your images/css/js files are all within zend/public/ and do not remove the zend/public/.htaccess file :)

不要忘记请求的 baseUrl 不包含/public",因此当您引用面向公众的文件时,您需要自己添加它.

Don't forget that the request's baseUrl doesn't include '/public', so you'll need to add it yourself when you reference public facing files.

问候,

抢...

这篇关于Zend 和 .htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆