试图把一个例外,重写规则在.htaccess [英] Trying to put an exception to RewriteRule in .htaccess

查看:253
本文介绍了试图把一个例外,重写规则在.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重定向所有的请求,像这样:

I am redirecting all requests like so:

RewriteRule ^sitemap.xml$ sitemap.php?/ [QSA,L]

# the line below is the one I'm having trouble with

RewriteCond %{REQUEST_URI}  !^market-reports$ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php?section=$1 [QSA,L]

我所有的导入链接是为了去的index.php,你可以看到。但现在我想从去那里停之一。我从来没有写我自己的的RewriteCond 之前,所以我有点不确定,如果我做的是正确的。

All my incoming links are meant to go to index.php, as you can see. But now I want to stop one from going there. I've never written my own RewriteCond before, so I'm a little unsure if what I am doing is correct.

基本上我想说的是:?如果输入的URL是一个文件,目录或/市场报告/什么也不做,否则发送该URL的index.php节=

Basically what I'm trying to say is: "If incoming URL is a file, directory or /market-reports/ do nothing. Otherwise send on the URL to index.php?section="

我是什么做错了吗?谢谢

What am I doing wrong? Thanks

推荐答案

所以,你只需要忽略 http://yourdomain.com/market -reports 的(除文件/目录?)。您应该罚款:

So you just need to ignore http://yourdomain.com/market-reports (in addition to files/directories?). You should be fine with:

RewriteCond %{REQUEST_URI} !^/market-reports/?$

这将(不)匹配http://yourdomain.com/market-reports以及http://yourdomain.com/market-reports/

This will (not) match "http://yourdomain.com/market-reports" as well as "http://yourdomain.com/market-reports/"

这篇关于试图把一个例外,重写规则在.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆