dongyao5186 2014-03-23 11:55
浏览 58
已采纳

PHP网站基础目录结构

I have a newsletter 3rd party system. It has been working really well however I have come across an issue which I'm hoping is a really easy fix.

So this is the root structure of my website

FTP SERVER
/index.php
/news.php
/shane/shane_about.php
/mailist/globals.php
/mailist/mailbar.php
/mailist/mailbar8.php

So I have an input box which allows me to register for a newsletter. It works a treat on index.php and news.php however screws up the whole page on shane_about.php because its in a child directory shane.

Now the problem is in the globals.php

<?php 
$main_dir = "maillist/";
$website = "http://www.mysite.com/";
$relative_string="index.php?page=mail&";
$absolute_path="/hostingcompanyserver/something/something/something.com/maillist/";
$lang="lang_english.php";

So I changed the variable $main_dir to "../mailist/"

This then worked on the shane/shane_about.php, then index.php and news.php had the same issue (it screwed up).

I'm sure the solution is very basic, any thoughts would be appreciated. Thanks Chris

  • 写回答

1条回答 默认 最新

  • dongxing4643 2014-03-23 12:14
    关注

    Change $main_dir to an absolute path.

    If it's the same as $absolute_path you won't have this problem.

    $main_dir = "/hostingcompanyserver/something/something/something.com/maillist/";
    

    The problem at the moment is index.php and news.php look inside maillist as defined by $main_dir. shane_about.php looks inside /shane/maillist/.

    You then told it to go up a directory to maillist with ..maillist/. This meant shane_about.php was looking in the right place but index.php and news.php weren't.

    By using an absolute path all files look in the same place.

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

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面