dsbiw2911188 2015-08-13 15:00
浏览 44

域如何访问子域数据?

I have a CMS for my website which is hosted on the subdomain (admin.example.com). Both are in a different directory on the server. On the subdomain I upload all my files (mostly images) that are later to use on the main domain (example.com).

From the subdomain I upload file information to the database which is also used by the main domain, file_url, file_id etc. etc.

The thing is, how can I get hold of this information from my main domain? The file_urls currently look like ../folder/image.png and I don't want people, using the main domain, knowing that I have a subdomain which holds the CMS.

I was thinking about throwing everything on the main domain and restrict the admin area for default users. But what are your thoughts about this? is this safe? is there somehow a work-around?

UPDATE
Within a page from the subdomain.example.com I call this piece of code

$dir = "/usr/share/nginx/html/example.com/public_html/images/thumbnail";
    try {
        // Creating directory
        mkdir($dir, 0755, true);

    } catch(ErrorException $ex){
            //  Failure
        die($warnings[] =  "Error: " . $ex->getMessage());
    }
    exit();

This works, folders have 755 and files 644. It may be a dirty workaround but I am not aware of the consequences this may have. Please let me know!

  • 写回答

2条回答 默认 最新

  • dongye7231 2015-08-13 15:12
    关注

    You can point to the sub domain but it will be tricky ti hide the fact May I suggest you set the permissions for your sub domain to just execute for the public Eg Owner: read write execute Group: read, execute Everyone else, execute

    This way they can use your site but cannot read the sub folder

    Or set up a redirect header in your index.php file of your sub folder and direct them to the appropriate page

    评论

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失