Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image .htaccess子文件夹图像和样式表的重定向_Image_.htaccess_Stylesheet_Subdirectory - Fatal编程技术网

Image .htaccess子文件夹图像和样式表的重定向

Image .htaccess子文件夹图像和样式表的重定向,image,.htaccess,stylesheet,subdirectory,Image,.htaccess,Stylesheet,Subdirectory,使用.htaccess重定向是否可以使位于子文件夹中的所有样式表和图像路径指向根文件夹中的相应文件夹(图像/样式)?无需更改每个文件中的路径 让我试着更好地解释一下我的情况 我使用一个包含doctype和样式表链接的include(header.inc.php) <link href="styles/layout.css" rel="stylesheet" type="text/css"> 下面是文件结构/层次结构的示例 [ROOT FOLDER] ind

使用.htaccess重定向是否可以使位于子文件夹中的所有样式表和图像路径指向根文件夹中的相应文件夹(图像/样式)?无需更改每个文件中的路径

让我试着更好地解释一下我的情况

我使用一个包含doctype和样式表链接的include(header.inc.php)

    <link href="styles/layout.css" rel="stylesheet" type="text/css">
下面是文件结构/层次结构的示例

    [ROOT FOLDER]

    index.php

      /subfolder 
         subpage1.php
         subpage2.php
         subpage3.php

      /subfolder2
         subpage1.php
         subpage2.php
         subpage3.php 

     contact.php

     /images
     /styles
     /scripts
     /inc

您不需要使用重写来解决这个问题,现在只需要了解如何在HTML元素中正确定义源代码

不要这样做

<link href="styles/layout.css" rel="stylesheet" type="text/css">

这样做

<link href="/styles/layout.css" rel="stylesheet" type="text/css">

改变的是,您的路径不再是相对于要浏览的文件,而是相对于网站的根目录


希望有帮助

你能举例说明你想从什么开始,然后去什么吗?嘿,贝内兹,我更新了我的问题。希望这会有帮助,这更清楚。我现在已经回答了。谢谢你的帮助,贝内兹。我刚刚应用了你的解决方案,它是所有连接所需的。我觉得把我的问题复杂化了有点傻!别担心。像往常一样,知道怎么做很容易。
<link href="styles/layout.css" rel="stylesheet" type="text/css">
<link href="/styles/layout.css" rel="stylesheet" type="text/css">