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
htaccess文件重定向图像和css文件_Css_Image_.htaccess_Redirect - Fatal编程技术网

htaccess文件重定向图像和css文件

htaccess文件重定向图像和css文件,css,image,.htaccess,redirect,Css,Image,.htaccess,Redirect,我正在使用.htacess文件使用以下脚本重定向我的页面: *#domain/page/about RewriteRule ^page/(.*)/(.*)?$ detail.php?tag=$1 [NC] RewriteRule ^page/(.*)?$ detail.php?tag=$1 [NC]* #domain/about RewriteRule ^(.*)?$ detail.php?tag=$1 [NC] 脚本工作正常,但当我使用: #domain/about Rewr

我正在使用.htacess文件使用以下脚本重定向我的页面:

*#domain/page/about 
RewriteRule ^page/(.*)/(.*)?$  detail.php?tag=$1 [NC]
RewriteRule ^page/(.*)?$  detail.php?tag=$1 [NC]*

#domain/about 
RewriteRule ^(.*)?$  detail.php?tag=$1 [NC] 
脚本工作正常,但当我使用:

#domain/about 
RewriteRule ^(.*)?$  detail.php?tag=$1 [NC]
所有我的图像、JScript和css文件都被禁用


我知道这是由于上面的脚本造成的,但是我可以告诉.htaccess文件忽略重定向中的.css、.jpg文件,或者将它们放在原来的位置吗?

在重写规则之前添加这一行:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!index\.php/?)(.*)$  detail.php?tag=$1 [NC,QSA,L]
此行将阻止css、js和图像文件的重定向


还记得在重写规则中添加
L
标志,以将其标记为最后一条规则。

在重写规则之前添加此行:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!index\.php/?)(.*)$  detail.php?tag=$1 [NC,QSA,L]
此行将阻止css、js和图像文件的重定向


还记得在重写规则中添加
L
标志,将其标记为最后一个规则。

谢谢它起作用,但现在我的索引文件也重定向到detail.php。甚至在我提出建议之前,index.php重定向问题就已经存在。不过,请尝试更新我的答案中的代码。谢谢它的工作,但现在我的索引文件也重定向到detail.php。那么,index.php重定向的问题甚至在我的建议之前就存在了。不过,请尝试在我的答案更新代码。