htaccess的URL重写帮助

编程入门 行业动态 更新时间:2024-10-28 00:29:31
本文介绍了htaccess的URL重写帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下重写网址:

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs RewriteRule ^(.*)$ index.php?page=$1 [PT,L]

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

Now I want to add an exception, that if the URL is something like mysite/abc it should ignore it and all things inside it also. mysite/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重写帮助

本文发布于:2023-11-01 19:41:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!