html - 使用 htaccess 隐藏文件夹或路径 css js 文件

标签 html css mod-rewrite base-tag

我正在尝试这个:

.htaccess

# BEGIN 
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /proyect/rewrite/

RewriteRule ^css/(.*) /proyect/rewrite/wp-content/$1 

</IfModule>
# END 

html文件

<!DOCTYPE html>
<html>
<head>

<!-- H1 COLOR BLUE -->
<link href="http://localhost/proyect/rewrite/wp-content/css/customjd.css" rel="stylesheet" type="text/css" > 

<!-- H1 COLOR RED-->
<base  href="/customjd.css" >

</head>

<body>

<h1>hello world!</h1>

</body>

</html>

但是没有任何反应。 h1 不要改变它的颜色。

PD:在文件夹 wp-content 中存在 customjd.css h1 color red。

最佳答案

htaccess 代码编辑为:

RewriteEngine On

RewriteRule ^(css/.*\.css)$ /proyect/rewrite/wp-content/$1

将 HTML 代码更改为:

<!DOCTYPE html>
<html>
<head>
  <base href="/proyect/rewrite/">
  <link href="css/customjd.css" rel="stylesheet" type="text/css">
</head>
<body>
  <h1>hello world!</h1>
</body>
</html>

customjd.css 中的 CSS 代码是:

h1 {
  color: red;
}

关于html - 使用 htaccess 隐藏文件夹或路径 css js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33715958/

相关文章:

php - HTACCESS 问题导致 401 和多个 302

.htaccess - 如何使 .htaccess 在当前目录而不是子目录上工作?

javascript - 具有数据属性的多个下拉菜单切换

css - 无法在响应式菜单中将边距设置为零

jquery - 3 panel scrollto 窗口左右滚动但从中间开始

css - 为什么光标是: text changing my other cursors?

apache - 通过apache重写规则永久重定向

javascript - 尝试从 javascript 获取数据然后在 HTML 中显示时出错

javascript - 传递动态 Javascript HTML 的 ID

html - IE7 中的按钮换行