.htaccess mod_重写为不可见文件

.htaccess mod_重写为不可见文件,.htaccess,.htaccess,我遗漏了一些关于.htaccess的信息 工作树状: / /subdomain /subdomain/.htaccess /subdomain/index.php /assets /assets/... htaccess在子域内,我访问它时就像:http://subdomain.localhost/ 资产在子域之外,我执行了以下规则: RewriteRule ^assets/(.*)$ http://localhost/assets/$1 现在,当subdomain/index.php尝试加

我遗漏了一些关于.htaccess的信息

工作树状:

/
/subdomain
/subdomain/.htaccess
/subdomain/index.php
/assets
/assets/...
htaccess在子域内,我访问它时就像:
http://subdomain.localhost/

资产在子域之外,我执行了以下规则:

RewriteRule ^assets/(.*)$ http://localhost/assets/$1
现在,当subdomain/index.php尝试加载类似assets/style.css的内容时,rewriterule将重定向到
http://localhost/assets/style.css

当我尝试加载javascript文件时,问题出现了。它被识别为另一个域,无法正常工作

有没有办法使
http://subdomain.localhost/assets
用作(而不是重定向)
http://localhost/assets
通过某种神奇的重写规则或其他方式


我尝试了
^assets/(.*)$../assets/$1
,但它似乎不起作用。

请查看指令。在什么时候,这是与PHP相关的问题?接受使用PHP代码的答案。@Orlandolete:如果您接受PHP作为答案,请显示您迄今为止在PHP中尝试的内容。@Orlandolete只需编写一个
.htaccess
文件并将其存储在根目录中。而
资产/
子域/
的规则将不同。此外,您无法访问父目录,
.htaccess
只循环访问子目录。