重写基本规则- php

发布于 2024-09-09 23:36:37 字数 314 浏览 2 评论 0原文

内部网址:example.com/abc/xyz/rule.php?price=1&pass=2
外部URL:example.com/abc/xyz/rule/1/2

但是外部URL中的css、js文件没有生效。 我的 .htaccess 文件:

RewriteEngine On
RewriteBase /example.com/abc/
RewriteRule ^rule/([0-9]+)/([0-9]+)/?$ rule.php?price=$1&pass=$2

Internal URL: example.com/abc/xyz/rule.php?price=1&pass=2
External URL: example.com/abc/xyz/rule/1/2

But the css, js files are not coming into effect in the external URL.
My .htaccess file:

RewriteEngine On
RewriteBase /example.com/abc/
RewriteRule ^rule/([0-9]+)/([0-9]+)/?$ rule.php?price=$1&pass=$2

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

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

发布评论

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

评论(1

好多鱼好多余 2024-09-16 23:36:37

“问题”是相对 URL 是由客户端解析的,而不是由服务器解析的。解析相对 URL 的基本 URL 是当前文档的 URL。在您的情况下,基本 URL(路径)是 /abc/xyz/rule/1/2 而不是 /abc/xyz/rule.php?price=1&pass=2< /代码>。

现在您有几种方法可以解决此问题:

The “problem” is that relative URLs are resolved by the client and not by the server. And the base URL, the relative URLs are resolved from, is the URL of the current document. And in your case the base URL (path) is /abc/xyz/rule/1/2 and not /abc/xyz/rule.php?price=1&pass=2.

Now you have several ways to solve this:

  • Use relative URLs that are correctly resolvable from the actual base URL /abc/xyz/rule/1/2
  • Use absolute URLs that are independent from the base URL
  • Alter the base URL using HTML’s BASE element
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文