简体   繁体   English

href链接停止工作

[英]href Link Stopped Working

I have a href link that when clicked should open an Excel file located to that location. 我有一个href链接,单击该链接时应打开一个位于该位置的Excel文件。 It worked perfectly in Chrome and IE9, but since yesterday it just stopped working, although nothing was changed. 它可以在Chrome和IE9上完美运行,但是从昨天起它就停止了工作,尽管没有任何变化。

The code looks like this: 代码如下:

<?php
$file_name="MyFile.xlsx";
$folder_name="CurrentFolder" . "/";
$file_path='D:/AllFiles/';
$link1=$file_path. $folder_name. $file_name;
?>

<a href="<?php echo $link1 ?>" target=_blank>
    <div style="height:100%;width:100%"> 
                <?php echo "$link1"; ?>
    </div>
</a>

Edit: 编辑:

This is some of the httpd.conf file: 这是一些httpd.conf文件:

<Directory "c:/wamp/www/">
    Require local
</Directory>

<Directory "c:/wamp/www/site1/">
    Require all granted
 </Directory>

Alias "/ssfiles" "D:/AllFiles/CurrentFolder"
<Directory "D:/AllFiles/CurrentFolder">
    Require all granted
</Directory>

Because the D:/AllFiles/CurrentFolder folder is outside the DocumentRoot folder Apache is not allowed access to it. 因为D:/AllFiles/CurrentFolder文件夹在DocumentRoot文件夹之外,所以Apache不能访问它。 By this I mean when the user clicks the link you have created Apache sees a folder that it has not been told is it allowed to access and does not have rights to access. 我的意思是,当用户单击您创建的链接时,Apache会看到一个未被告知的文件夹,该文件夹被允许访问并且没有访问权限。

You need to create an Alias for folders stored outside the DocumentRoot so Apache know it is allowed to access them, and what they are called(alias) and who is allowed to request the data. 您需要为DocumentRoot外部存储的文件夹创建别名,以便Apache知道允许访问它们,以及它们的别名(别名)以及允许谁请求数据。

Alias "/ssfiles" "D:/AllFiles/CurrentFolder"
<Directory "D:/AllFiles/CurrentFolder">
    Require all granted
</Directory>

Then change the code to use the alias you have created, then anything that apache see's being requested from domain.tld/ssfiles/anyfilename.ext it will attempt to server from D:/AllFiles/CurrentFolder 然后更改代码以使用您创建的别名,然后从domain.tld/ssfiles/anyfilename.ext请求apache看到的所有内容,它将尝试从D:/AllFiles/CurrentFolder

<?php
$spreadsheet_alias  = 'ssfiles/';
$file_name          = 'MyFile.xlsx';
$link1= $spreadsheet_alias. $file_name;
?>    
<a href="<?php echo $link1 ?>" target=_blank>
    <div style="height:100%;width:100%"> 
        <?php echo "$link1"; ?>
    </div>
</a>

PS: This may have happened because we fixed something from this previous question PS:这可能是发生的,因为我们修复了上一个问题中的某些内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM