search
Homephp教程PHP开发How to force jpg, js, css and other resources to connect, if they do not exist, directly 404 without rewriting

怎么强制jpg,js,css等连接资源,如果不存在就直接404而不重写
我在本机架设了个网站
http://www.laji.com
网站文件夹下有2个文件,
.htaccess文件:

Options +FollowSymLinks -MultiViews<br>
RewriteEngine on<br>
RewriteBase /<br>
<br>
# All other pages<br>
# Don&#39;t rewrite real files or directories<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteCond %{REQUEST_URI} !^.*(\.<a href="http://www.php1.cn/category/72.html">css</a>|\.js|\.gif|\.png|\.jpg|\.jpeg)$<br>
RewriteRule ^(.*)$ index\.php?main_page=$1&%{QUERY_STRING} [L]<br>

index.php

<?php echo $_GET[&#39;main_page&#39;] ?>

 我使用http://www.laji.com/xxx.jpg (这个图片不存在),为什么还是被重写指向

http://www.laji.com/index.php?main_page=xxx.jpg?
怎么强制jpg,js,css等连接资源,如果不存在就直接404而不重写

分享到:


------解决方案--------------------
-s判断请求的文件是否是一个存在的非空文件;判断不是可以用:!-s

<br>
RewriteCond %{REQUEST_FILENAME} !-s  <br>


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)