ZEND-如何使其在共享主机上工作? [英] ZEND - How to make it works on a shared host?

查看:98
本文介绍了ZEND-如何使其在共享主机上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在共享主机上移动Zend网站,该主机使用的是Pretty URL,但是添加参数后css文件不会加载。在移动之前,我想确定要使用服务器IP地址进行测试。



例如

-SERVER_IP /〜用户名/ en(有效)< br>
-SERVER_IP /〜用户名/ en / news(失败,因为它在 en文件夹中搜索)



我想从中重定向每个CSS文件路径/ css /到我的真实css文件夹,其中有很多css文件。



对于每个路径/ images /和/ js /,甚至其他路径,我都希望有同样的东西。 p>

有人可以帮我吗?



谢谢!






更新1



域之间的路径相对变化。 com和SERVER_IP /〜用户名?当我设置/css/style.css时,它将搜索SERVER_IP / css / style.css而不是SERVER_IP /〜username / css / style.css。如果我能使两者同时适用,我的问题将不复存在。但是我无法使用domain进行测试,因为我暂时没有




UPDATE 2



我已在C:\windows\system32\drivers\etc\中修改了hosts文件,以使用真实域进行模拟。如我所料,相对路径的工作方式不同。

 -SERVER_IP /〜用户名/index.php< img src = / img / world.jpg /> => SERVER_IP / img / world.jpg(不好,请注意我已经失去了〜username)
-www.domain.com/index.php< img src = / img / world.jpg /> => www.domain.com/img/world.jpg(完美)

有了这一改变,我所有的道路现在很好,无需重定向任何内容。但是出现另一个问题。由于我使用www.domain.com,因此URL中显示了index.php,但我不希望这样:www.domain.com/index.php/en




更新3



我发现了以下规则: RewriteRule ^ index.php(。*)$ http://%{HTTP_HOST} / $ 1 [R = 301,NC,L] 。 index.php现在已删除,但是当我进入www.domain.com/en时,好像en不在请求uri中,我所有的链接都移至www.domain.com/en/en / ...



我在这里粘贴我的.htaccess内容:

  Options + FollowSymLinks 
选项-在
RewriteBase上索引
RewriteEngine /

DirectoryIndex index.php index.html

RewriteCond%{REQUEST_FILENAME} -f [OR ]
RewriteCond%{REQUEST_FILENAME} -d
RewriteRule。*-[L]

RewriteCond%{REQUEST_FILENAME} -s [OR]
RewriteCond%{REQUEST_FILENAME} -l [OR]
RewriteCond%{REQUEST_FILENAME} -d
RewriteRule ^。* $-[NC,L]

RewriteRule ^ index.php(。*)$ http ://%{HTTP_HOST} / $ 1 [R = 301,NC,L]




更新4



我明白了!我在下面描述我的整个解决方案!



解决方案

完整的最终解决方案



我找到了一个解决方案,现在在共享主机上一切正常。这是我完整的解决方案,希望它可以节省很多时间。



1-完整的Zend体系结构(D =目录,F =文件)

 -public_html / 
(D)应用程序/
(D)数据/
(D)库/
(D)docs /
(D)nbproject /
(D)public /
(F)index.php
。 ..
(F).htaccess

2-删除基本的.htaccess文件放在 public /文件夹中,并将其放置在根文件夹 public_html /(或../public)中。

  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]

END !!! 这就是您所要做的,无所事事更多,没有棘手或肮脏的代码!此.htaccess文件解决了httpd.conf文件中用于共享托管的DOCUMENT_ROOT配置问题。



重要提示

如果您的网域当时没有转发(或者您想在将主机从服务器移至另一台服务器之前进行测试(我的情况)),并且您想使用这种URL访问您的网站
http :// SERVER_IP /〜用户名/ ,它将不起作用。最好的解决方案是临时编辑C:\windows\system32\drivers\etc temporal中的主机文件,以添加如下行:

SERVER_IP域。 com 很棒!


I have to move a Zend website on a shared hosting which is using Pretty URL but css files doesn't load when params is added. Before moving, i want to test with server ip adress to be sure.

For exemple
-SERVER_IP/~username/en (works)
-SERVER_IP/~username/en/news (fails because it search in "en" folder)

I would like to redirect every css files from path /css/ to my real css folder which has many css files.

I want same thing for every path /images/ and /js/ and maybe others.

Can someone help me ?

thank you!


UPDATE 1

Does path relative change between domain.com and SERVER_IP/~username? When i set /css/style.css, it search for SERVER_IP/css/style.css instead of SERVER_IP/~username/css/style.css. If i can make it works for both, my problems will be gone. But I can't test with domain because i don't have any for the moment


UPDATE 2

I've modified my hosts file in C:\windows\system32\drivers\etc\ to simulate with a real domain. As i expect, relative path aren't working the same ways.

- SERVER_IP/~username/index.php <img src="/img/world.jpg" /> => SERVER_IP/img/world.jpg (BAD, note i've lose ~username)
- www.domain.com/index.php <img src="/img/world.jpg" /> => www.domain.com/img/world.jpg (perfect)

With that change, all my path are good now and no need to redirect anything. But another problem appears. Since i use www.domain.com, index.php is shown in the URL and I don't want this : www.domain.com/index.php/en


UPDATE 3

I've found this rule : RewriteRule ^index.php(.*)$ http://%{HTTP_HOST}/$1 [R=301,NC,L] . index.php is now remove but when i'm on www.domain.com/en, it looks like en is not in the request uri and all my links move to www.domain.com/en/en/...

I paste here my .htaccess content :

Options +FollowSymLinks
Options -Indexes
RewriteEngine on
RewriteBase /

DirectoryIndex index.php index.html

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

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

RewriteRule ^index.php(.*)$ http://%{HTTP_HOST}/$1 [R=301,NC,L]



UPDATE 4

I got it ! I describe my entire solution below!



解决方案

COMPLETE FINAL SOLUTION

I've found a solution, everything is working #1 now on a shared hosting. Here is my complete solution, I hope it will save a lot of time to somebody.

1- Complete Zend Architecture (D=Directory, F=File)

- public_html/ 
      (D) application/
      (D) data/
      (D) library/
      (D) docs/
      (D) nbproject/
      (D) public/
           (F) index.php
               ...
      (F) .htaccess

2- Remove the basic .htaccess file in "public/" folder and place this one in the root folder "public_html/" (or ../public)

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]

END !!! It's all you have to do, nothing more, no tricky or dirty code! This .htaccess file solve the DOCUMENT_ROOT config problem in httpd.conf file for shared hosting.

IMPORTANT NOTE
If your domain is not forwarded at that moment (OR you want to test before moving host from a server to another (my case)) and you want to access to your website with that kind of URL
http://SERVER_IP/~username/, it will not works. The best solution is to temporaly edit your hosts file in C:\windows\system32\drivers\etc\ to add a line like this :
SERVER_IP domain.com It works great!

这篇关于ZEND-如何使其在共享主机上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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