dttl3933 2014-10-04 13:03
浏览 13
已采纳

ZEND - 如何使它在共享主机上运行?

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!



  • 写回答

1条回答 默认 最新

  • duanraa1984 2014-10-05 18:01
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证