gpt4 book ai didi

php - Mod_rewrite,试图排除图像和 css 文件

转载 作者:行者123 更新时间:2023-11-28 17:42:02 25 4
gpt4 key购买 nike

我正试图找到一种从我的 mod_rewrite 权限中排除图像文件和 css 文件的方法

Options +FollowSymLinks
RewriteEngine On

#SecFilterInheritance Off
ErrorDocument 404 /fourohfour.php

RewriteCond %{HTTP_HOST} ^(myurl\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !\.(?:css|png|jpe?g|gif)$ [NC,OR] #my attempt at excluding

RewriteRule ^articles/([^/]+)/([^/]+)/?$ /article.php?id=$1&articleTopic=$2 [QSA,L]

问题是排除行不太准确,我需要帮助

如果我转到我的目录中未包含在我的 .htaccess 重写中的任何 phpscript.. 说 isntance www.myurl.com/articlelinks.php 我将被重定向到此:

http://www./articlelinks.php  

更复杂的是:

如果我去: http://www.myurl.com/articles/1/Dorsal+and+Volar+Intercalated+Segment+Instability+(DISI+and+VISI) CSS 文件不加载

如果我去:

http://www.myurl.com/articles.php?id=1&articleTopic=Dorsal+and+Volar+Intercalated+Segment+Instability+(DISI+and+VISI)正确的文档加载了 css 和图像

请帮忙?

最佳答案

你的条件中有一个 OR 标志,但它后面没有其他条件,这让 mod_rewrite 认为:%{REQUEST_URI} !\.(?:css|png |jpe?g|gif)$ 或(任何)。尝试删除 OR

RewriteCond %{REQUEST_URI} !\.(?:css|png|jpe?g|gif)$ [NC]
RewriteRule ^articles/([^/]+)/([^/]+)/?$ /article.php?id=$1&articleTopic=$2 [QSA,L]

您的 CSS 未加载的原因可能是因为您在文档中使用了相对 URL 路径。尝试将这些链接更改为绝对 URL 路径(以 / 开头)或将其添加到页面的标题中:

<base href="/" />

空白主机问题,不知道为什么会这样。尝试添加此条件:

RewriteCond %{HTTP_HOST} !^$

所以规则看起来像:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^(myurl\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

关于php - Mod_rewrite,试图排除图像和 css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23938859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com