Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.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
Php 如何使用.htaccess规则从父目录加载.css文件?_Php_Html_Css_.htaccess_Mod Rewrite - Fatal编程技术网

Php 如何使用.htaccess规则从父目录加载.css文件?

Php 如何使用.htaccess规则从父目录加载.css文件?,php,html,css,.htaccess,mod-rewrite,Php,Html,Css,.htaccess,Mod Rewrite,我的.htaccess文件中有两条规则。 第一个是隐藏父文件夹中所有文件的扩展名,第二个是删除.php值和文件id,以及“创建”并在子文件夹子文件夹中显示该URL。问题是子文件夹中的文件无法加载.css和.js文件,因为它们位于父/css和父/js文件夹中。我得到:“加载资源失败:服务器响应状态为404(未找到)”。 找不到任何更改路径的规则,或者可能排除该css/js文件 这是我的文件夹结构: /parent/ |__ .htaccess |__ index.php |__ about.php

我的
.htaccess
文件中有两条规则。 第一个是隐藏父文件夹中所有文件的扩展名,第二个是删除
.php
值和文件
id
,以及“创建”并在子文件夹
子文件夹中显示该URL。问题是
子文件夹中的文件
无法加载
.css
.js
文件,因为它们位于
父/css
父/js
文件夹中。我得到:“加载资源失败:服务器响应状态为404(未找到)”。 找不到任何更改路径的规则,或者可能排除该
css/js
文件

这是我的文件夹结构:

/parent/
|__ .htaccess
|__ index.php
|__ about.php
|__ details.php
|__ CSS
|  |__style.css
|__ JS
|  |__script.js
以下是我的规则:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)$ $1.php
RewriteRule ^subfolder/([^/]+)$ /parent/details.php?value=$1 [L]

在.htaccess的顶部插入此规则:

RewriteRule ^(?!parent/)[^/]+/((?:CSS|JS)/.+)$ /parent/$1 [L,NC,R]

哇,这很有帮助!非常感谢,朋友!:)