Zend的和.htaccess [英] Zend and .htaccess

查看:241
本文介绍了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]

我用这个默认的URL来访问应用程序

I use this default url to access the app

http://domain/index.php

我现在已经搬到了一个共享的主机,其中,Web根目录是上面的'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

我希望能够用

i want to be able to use

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]

有人能发现什么?

Can anybody spot anything?

推荐答案

创建的Zend / index.php文件包含此code:

Create zend/index.php containing this code:

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

现在创建的Zend /的.htaccess包含此code:

Now create zend/.htaccess containing this code:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteRule .* index.php

请确保您的图片/ CSS / JS文件都在的Zend /公/不要删除了Zend /公/ .htaccess文件:)

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

不要忘了请求的的baseUrl不包括'/公众,所以你需要自己添加它,当你引用面向公众的文件。

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天全站免登陆