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条)

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂