覆盖使用htaccess的阿帕奇重写规则

编程入门 行业动态 更新时间:2024-10-24 18:18:53
本文介绍了覆盖使用htaccess的阿帕奇重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

承载多个域的服务器上工作。某处在Apache的配置是为所有域的重写规则。

会发生什么,如果一个用户进入example/foo~~V他们应该重定向到example/foo_bar~~V是

然而,在一个领域,我要覆盖此行为,以便该URL停留在example/foo并不会重定向。我一直在寻找和尝试不同的规则和条件无济于事。我没有访问Apache的配置,但我使用的.htaccess对这一领域的一些重写规则。

这是我的重写规则在.htaccess:

< IfModule mod_rewrite.c>    RewriteEngine叙述上    #这是不工作    #重写规则^(富)($ | /) - [L]    的RewriteBase /    的RewriteCond%{} REQUEST_FILENAME!-d    的RewriteCond%{} REQUEST_FILENAME!-f    重写规则^(。*)$的index.php?/ $ 1    #这个没有任何工作    #^重写规则/富的index.php?/ $ 1 [L]< / IfModule>

解决方案

尝试重定向 / foo_bar这样的名称回 /富。

当阿帕奇通过他们多次,而当你的打开调试。我觉得发生了什么你的情况是,你想在第一遍匹配URI,但是Apache已经就修改 / foo_bar这样的名称。

此外,作为调试的问题,你应该尝试重新创建你控制的环境问题。询问你的系统管理员为全球配置的副本,并镜像设置你限制在

working on a server that hosts multiple domains. Somewhere in apache config is a rewrite rule that is set for ALL domains.

What happens is if a user goes to example/foo they are supposed to get redirected to example/foo_bar

However, in one domain, I want to override this behavior so that the url stays at example/foo and does not redirect. I've been searching and trying various rules and conditions to no avail. I don't have access to the apache config, but I am using .htaccess for some rewrite rules on this domain.

here's my rewrite rules in .htaccess:

<IfModule mod_rewrite.c> RewriteEngine on # this isn't working # RewriteRule ^(foo)($|/) - [L] RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?/$1 # this didn't work either # RewriteRule ^/foo index.php?/$1 [L] </IfModule>

解决方案

Try redirecting /foo_bar back to /foo.

When Apache processes the rewrite rules it runs through them multiple times, which you can see when you turn on debugging. I think what's happening in your case is that you're trying to match the URI in the first pass, but Apache has already modified it to /foo_bar.

Also, as a matter of debugging, you should try to recreate the problem in an environment you control. Ask your sysadmin for a copy of the global configuration and mirror the set up you're constrained to.

更多推荐

覆盖使用htaccess的阿帕奇重写规则

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

发布评论

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

>www.elefans.com

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