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
.htaccess 用于css和js url重写的htaccess代码不起作用_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 用于css和js url重写的htaccess代码不起作用

.htaccess 用于css和js url重写的htaccess代码不起作用,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我正在为缓存问题实施以下解决方案: 但在更改css文件的名称后,浏览器无法找到该文件。 当我手动打开它时,它给出404错误 这是我完整的.htaccess代码: RewriteEngine on RewriteBase /App RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRul

我正在为缓存问题实施以下解决方案:

但在更改css文件的名称后,浏览器无法找到该文件。 当我手动打开它时,它给出404错误

这是我完整的.htaccess代码:

RewriteEngine on
RewriteBase /App
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
我的css文件路径是: /资产/master.css


基本上,我想做的是动态地将所有css&js文件重写为:master.1454667174.css

我希望服务器忽略文件扩展名前的10位数字,只将master.css文件返回到浏览器


请帮助..

url重写会影响文件路径。您必须在css或js文件路径中添加“/”。 示例:原始文件路径->css/style.css

您必须执行->/css/style.css

这与js和图像路径相同

您必须将基本url链接放在头标签中


参考此内容以获取基本url html语法

基本上,我要做的是动态地将所有css&js文件(如master.1454667174.css)重写为:master.css