重写显示没有图片和外部JavaScript只有文字 [英] rewrite showing only text without pictures and external javascript

查看:92
本文介绍了重写显示没有图片和外部JavaScript只有文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下code:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]
RewriteRule ^newfolder/(.*)$ /index.html [L,NC]

但问题是,因为它改写一切index.html的 - 这意味着图像和外部JavaScript将不可见(加载)...它只是重写的index.html(文字),但其他的东西,从指数没有(图片,外部JavaScript)。 使用[L,NC,R]工作,但蒙山[L,NC]没有,我不希望观众看到的其他网页。 我想告诉游客充分的index.html和所有它的内容 - 但它没有显示图片,外部JavaScript

Problem is because it rewrite everything to index.html - it means that picture and external JavaScript won't be seen (loaded)... It only rewrite index.html (text) but other stuff from index not (picture, external JavaScript). With [L,NC,R] work but whith [L,NC] not and I don't want visitors to see that is other page. I want to show visitor full index.html with all it's content - but it is not showing pictures, external JavaScript.

推荐答案

您需要2 的RewriteCond 线,以排除此重写文件和目录:

You need to 2 RewriteCond lines to exclude files and directories from this rewrite:

# fixed css/js/images
RewriteRule ^newfolder/((?!index).+?\.(?:jpe?g|gif|bmp|png|tiff|css|js|html?))$ /$1 [L,R=301,NC]

RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^newfolder/(.*)$ /index.html [L,NC]

这篇关于重写显示没有图片和外部JavaScript只有文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆