Rumah  >  Artikel  >  pembangunan bahagian belakang  >  如何强制jpg,js,css等连接资源,如果不存在就直接404而不重写

如何强制jpg,js,css等连接资源,如果不存在就直接404而不重写

WBOY
WBOYasal
2016-06-13 12:34:58942semak imbas

怎么强制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't rewrite real files or directories<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg)$<br />
RewriteRule ^(.*)$ index\.php?main_page=$1&%{QUERY_STRING} [L]<br />

index.php
<?php echo $_GET['main_page'] ?>


我使用http://www.laji.com/xxx.jpg (这个图片不存在),为什么还是被重写指向
http://www.laji.com/index.php?main_page=xxx.jpg?
怎么强制jpg,js,css等连接资源,如果不存在就直接404而不重写

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn