Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache .htacces重写全部以索引/忽略图像和css文件_Apache_.htaccess - Fatal编程技术网

Apache .htacces重写全部以索引/忽略图像和css文件

Apache .htacces重写全部以索引/忽略图像和css文件,apache,.htaccess,Apache,.htaccess,我使用以下.htaccess文件将所有请求发送到索引文件。 但是现在我想忽略来自/static文件夹的所有内容 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] 所以,事情是这样的: - index.php - static/ ----img --------bg.jpg ----css --------main.css 目前,样式和图像的子页面上无法再加载。我想放弃使用完整路径。

我使用以下.htaccess文件将所有请求发送到索引文件。 但是现在我想忽略来自
/static
文件夹的所有内容

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
所以,事情是这样的:

- index.php
- static/
----img
--------bg.jpg
----css
--------main.css

目前,样式和图像的子页面上无法再加载。我想放弃使用完整路径。

那么,您需要添加一个例外,对吗

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/static/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
您可以尝试以下规则:

RewriteEngine on

RewriteCond %{THE_REQUEST} !/static/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

对于负面条件,最好使用
请求
,因为
请求
变量不会被其他规则覆盖。

对不起,我昨天迟到了
-f
应该已经阻止将确实存在的文件重写为index.phpI,但它不起作用,这是我使用的图像标记
。当我访问example.com/event/edit这样的链接时,徽标丢失了。我假设这是相对路径与绝对路径的问题。您提供的关于实际设置的信息很少。试试这个条件:
RewriteCond%{REQUEST\u URI}/静态/
…我试过了,但是url现在看起来像这样:
http://localhost/gemeinde/event/register/static/img/logo.png
它应该是这样的:
http://localhost/gemeinde/static/img/logo.png
此部分是基本链接:
http://localhost/gemeinde
您要求一条规则来忽略静态文件,这就是该规则的作用。现在看来你遇到了另一个问题。您如何在HTML页面中使用图像链接?
我无法设置/static/,因为页面可能位于子文件夹中。要解决此问题,您需要在页面HTML的
标记下方添加此链接:
@anubhava,您好,先生,所以
请求
url的意思类似于
http:test.singh.com/test/test/test/static/test
?并检查在该请求中是否未找到静态关键字?如果您能在这里指导,我将不胜感激。