重写显示没有图片和外部JavaScript只有文字重写、文字、图片、JavaScript

由网友(Casset(宠爱))分享简介:我有以下code:RewriteEngine OnRewriteBase /RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]RewriteRule ^newfolder/(.*)$ /index.html [L,NC]但问题是,因为它改写...

我有以下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]
阅读全文

相关推荐

最新文章