重写基本规则- php
内部网址: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“问题”是相对 URL 是由客户端解析的,而不是由服务器解析的。解析相对 URL 的基本 URL 是当前文档的 URL。在您的情况下,基本 URL(路径)是
/abc/xyz/rule/1/2
而不是/abc/xyz/rule.php?price=1&pass=2< /代码>。
现在您有几种方法可以解决此问题:
/abc/xyz/rule/1/2
BASE
元素<的基本 URL /a>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:
/abc/xyz/rule/1/2
BASE
element