2017-10-14 124 views
0

我有一個包含不同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的代碼請任何幫助 –

回答

0

我無法確定,因爲您沒有提供如何使用您定義的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' 
    
相關問題