.htaccess 帮助 RewriteRule

发布于 2024-08-28 17:50:59 字数 284 浏览 0 评论 0原文

我有一个问题,惊讶;)

我在 Apache 中使用 .htaccess 并有一个 RewriteRule 问题

我的代码是

RewriteRule ^(.*)$       /system/header_codes.php?oldurl=$1

如果它没有真正的( rewriterule )我该如何制作所以使用这个,我将使用它因为我创建了一个动态 RewriteRule对于我的系统中的客户?

我希望在这里得到帮助,对于拼写错误表示歉意。

I have a problem, surprise ;)

I use .htaccess in Apache and have a RewriteRule problem

My code is

RewriteRule ^(.*)$       /system/header_codes.php?oldurl=$1

How can I make if it did not have a true ( rewriterule ) so use this, I will use it becures i create a dyanmic RewriteRule for my customer in my System?

i hope for help here, sorry for bad spelling.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔一刀 2024-09-04 17:50:59

我可能离这里很远,因为我几乎不明白你在问什么,但这也许会有所帮助。这是我用来将所有内容发送到我的请求处理程序(index.php)的重写规则。它不会重定向 css、图像等文件,因此也许您可以使用该逻辑来排除其他模式。

RewriteRule !(\.(css|jpg|png|gif|jpeg|js|swf))$ index.php [NC]

I might be way off here becuase I barely get what you're asking, but maybe this will help a little. It's the rewrite rule I use to send everything to my request handler (index.php). It doesn't redirect css, image, etc files, so maybe you can use that logic to exclude other patterns.

RewriteRule !(\.(css|jpg|png|gif|jpeg|js|swf))$ index.php [NC]
风蛊 2024-09-04 17:50:59

您的问题有点难以理解,但如果我没有记错的话,如果重写规则不匹配,您希望将用户重定向到自定义页面。

现在我将解释这个问题:

重写规则旨在拦截对某些URL的请求并将它们重定向到另一个页面。如果规则不匹配,则不会发生并且网络服务器会正​​常处理请求。

您可以做的是在 .htaccess 文件中设置一条规则,将对不存在页面的请求重定向到另一个文件。 (请参阅此处

Your question is a little hard to understand, but if I'm not mistaken, you want to redirect the user to a custom page IF the rewrite rule is not matched.

Now I will explain the problem with that:

The rewrite rule is designed to intercept requests to certain URLs and redirect them to another page. If the rule is not matched, nothing happens and the request is handled normally by the webserver.

What you can do, is set a rule in your .htaccess file to redirect requests to nonexistent pages to another file. (See here)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文