douchong4730 2014-09-20 16:31
浏览 24
已采纳

子域上的Fat Free Framework配置

I am trying to deploy an Fat Free Framework app on a subdomain. It worked fine on my local server but I get a blank page on deploying it on a sub-domain on a live site. I believe I somehow got my configurations (.htaccess, config/routes) wrong but I've tried several but can't get it to work. My configs are:

.routes file

[routes]
GET /games/@gameid/@move = WebPage->getgames

.config file

[globals]
AUTOLOAD = app/;third_party/;third_party/phpQuery/
DEBUG = 0
UI = views/
ENCODING = utf-8
LOGS= tmp/cache/

.htaccess file

#mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,QSA]

#Hotlinking Protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.domain.com/.*$ [NC]
RewriteRule \.(js|css|jpg|gif|png|bmp|mp4|3gp|m4a|m4r|aac|mp3|ogg|wave)$ - [F]

#PHP code in HTML file
AddType fcgid-script .php .htm .html .phtml

I'm on PHP Version 5.3.28 Apache 2.3.7

Folder Structure

subdomain.domain.com (subdomain folder)

  • .htaccess file
  • index.php file
  • app folder
  • db folder
  • views folder
  • third_party folder
  • tmp folder

On my local server I have .htaccess file like this

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
  • 写回答

2条回答 默认 最新

  • donglian3061 2014-09-20 16:36
    关注

    This seems incorrect:

    RewriteBase /subdomain.domain.com
    

    I would change it to simply be this:

    RewriteBase /
    

    The reason being is RewriteBase only refers to the URL base of the server itself and not anything further “to the left” of that. Meaning if this is your main site URL:

    http://subdomain.domain.com

    Setting a RewriteBase /subdomain.domain.com would mean that the rules would only act on the URL of :

    http://subdomain.domain.com/subdomain.domain.com

    And to make it a bit clearer, one would only adjust RewriteBase / (an then the corresponding RewriteRule) if the code is running on a path “to the right” of the base URL. So let’s say you installed it in the directory mycoolapp/ and you wanted that to be accessible like this:

    RewriteBase /mycoolapp/
    

    And then you would have to adjust the RewriteRule for the index.php like this:

    RewriteRule . /mycoolapp/index.php [L,QSA]
    

    EDIT: Based on you providing the .htaccess for your local setup, you have this for your mod_rewrite:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L,QSA]
    

    But on your subdomain setup you have this:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L,QSA]
    

    Why the radical difference? Just use the mod_rewrite stuff that works from your local setup. Specifically get rid of this line on your subdomain setup:

    RewriteBase /
    

    And change this line:

    RewriteRule . /index.php [L,QSA]
    

    To be this:

    RewriteRule .* index.php [L,QSA]
    

    So the final subdomain .htaccess should have this:

    #mod_rewrite on
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L,QSA]
    
    #Hotlinking Protection
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.domain.com/.*$ [NC]
    RewriteRule \.(js|css|jpg|gif|png|bmp|mp4|3gp|m4a|m4r|aac|mp3|ogg|wave)$ - [F]
    
    #PHP code in HTML file
    AddType fcgid-script .php .htm .html .phtml
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)