htaccess的URL重写帮助 [英] htaccess url rewrite help

查看:209
本文介绍了htaccess的URL重写帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下重写网址:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]

现在我想添加一个例外,即如果URL是这样mysite.com/abc应该忽略它,并在它里面所有的东西也。 mysite.com/abc/dfgs也应排除这个重写。

Now I want to add an exception, that if the URL is something like mysite.com/abc it should ignore it and all things inside it also. mysite.com/abc/dfgs also should be excluded from this rewriting.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

如果/ ABC是现有的目录,你可以把在那里的另一个.htaccess文件以

If /abc is an existing directory, you can put another .htaccess file in there with

RewriteEngine Off

如果这是真的,你要不能重写(它是否存在与否)只是一个字符串

If it's really just one string you want to not rewrite (whether it exists or not)

RewriteCond %{REQUEST_URI} !^/abc

如果请求的路径以/ ABC

will not rewrite if the requested path starts with "/abc"

要测试重写规则没有搞乱的网站经常浏览器(不是说你应该在编辑过程中的现场环境,这纯粹是假设的:-)),我发现以下非常有帮助的:

To test rewrite rules without messing up the site for regular browsers (not that you should be editing in a live environment of course, this is purely hypothetical :-) ), I've found the following very helpful:

RewriteCond %{REMOTE_ADDR} 12.34.56.78 # <-- where that's your IP address

这篇关于htaccess的URL重写帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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