PHP路径在本地主机上运行脚本翻倍

问题描述:

我有一个包含不同php文件和sql数据库的网站。它是一个内容管理网站。我试图在本地主机上使用此路径上的XAMPP服务器对其进行测试: localhost/avs avs是索引和所有其他文件所在的文件夹。 当我开始的网站,它显示了一个闪屏,但不会去进一步链接,因为链接双打: ENTER键:本地主机/ AVS改变到本地主机/AVS /本地主机/ AVSPHP路径在本地主机上运行脚本翻倍

继为configs.paths.php其中我插入本地主机路径的代码,[只有01处BASE_URL我改变时,所有其余的是默认]:

<?php 
defined('_VALID') or die('Restricted Access!'); 
$config = array(); 
$config 

['BASE_URL'] = 'localhost/avs'; 
$config['RELATIVE'] = ''; 
$config['BASE_DIR'] = 

dirname(dirname(__FILE__)); 
$config['TMP_DIR'] = $config['BASE_DIR']. '/tmp'; 
$config['LOG_DIR'] = $config['BASE_DIR']. '/tmp/logs'; 
$config['IMG_DIR'] = 

$config['BASE_DIR']. '/images'; 
$config['IMG_URL'] = $config['BASE_URL']. 

'/images'; 
$config['PHO_DIR'] = $config['BASE_DIR']. '/media/users'; 
$config 

['PHO_URL'] = $config['BASE_URL']. '/media/users'; 
$config['VDO_DIR'] = $config 

['BASE_DIR']. '/media/videos/vid'; 
$config['VDO_URL'] = $config['BASE_URL']. 

'/media/videos/vid'; 
$config['FLVDO_DIR'] = $config['BASE_DIR']. 

'/media/videos/flv'; 
$config['FLVDO_URL'] = $config['BASE_URL']. 

'/media/videos/flv'; 
$config['TMB_DIR'] = $config['BASE_DIR']. 

'/media/videos/tmb'; 
$config['TMB_URL'] = $config['BASE_URL']. 

'/media/videos/tmb'; 

$config['HD_DIR'] = $config['BASE_DIR'].'/media/videos/hd'; 
$config['HD_URL'] = $config['BASE_URL'].'/media/videos/hd'; 
$config 

['IPHONE_DIR'] = $config['BASE_DIR'].'/media/videos/iphone'; 
$config 

['IPHONE_URL'] = $config['BASE_URL'].'/media/videos/iphone';   
?> 

htaccess的:

# Comment the 2 lines below if the server returns 500 errors! 
Options -Indexes 
Options +FollowSymLinks 

#Uncomment following lines if you want to use image caching! 
#<IfModule mod_expires.c> 
# ExpiresActive On 
# ExpiresDefault A1209600 
# ExpiresByType text/html A1 
#</IfModule> 

# Uncomment following lines if Apache doesnt support MultiViews! 
<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # Uncomment the 2 lines below if you are using www.domain.com 
    # as the baseurl for the site and users access your site 
    # via domain.com (THIS IS REQUIRED FOR JQUERY TO WORK) 

    RewriteCond %{HTTP_HOST} ^yourdomain.com [NC] 
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule .* loader.php [L,QSA] 
</IfModule> 

# Edit below lines and set to 
# ErrorDocument CODE /RELATIVE/error.php 
# If the script is installed in the default document 
# root then relative is null. 
#ErrorDocument 401 /error.php 
#ErrorDocument 403 /error.php 
#ErrorDocument 404 /error.php 

其他信息:sql数据库链接成功(已测试)

+0

请检查htaccess是否存在?有没有可以保存网址的桌子?你能分享屏幕截图了解更多细节吗? –

+0

@PramodKharade先生我编辑了帖子,并添加了我的文件夹中的AVS脚本 –

+0

htaccess的代码请任何帮助 –

我无法确定,因为您没有提供如何使用您定义的URL的示例,但似乎您正在尝试构建绝对URL到不同的页面,问题是,你必须定义为基准网址为:

$config['BASE_URL'] = 'localhost/avs' 

包括主机名,但没有包括http://,所以如果你做这样的事情:

<img scr="<?php echo $config['IMG_URL']?>/image.jpg"> 

你得到一个相对URL,而不是绝对的,并列入http://localhost/avs/index.php将指向http://localhost/avs/localhost/avs/[anything],因为相对URL是相对于它们所包含的文件的路径中的任何URL。

换句话说,不包括http://https://主机名被解释为路径的另一个目录。

你有两种选择,以解决这个问题:

  • 转换成绝对URL,包括在基础URL的http://所有网址:

    $config['BASE_URL'] = 'http://localhost/avs' 
    
  • 使用的URL相对于根目录下(不包括主机名):

    $config['BASE_URL'] = '/avs'