重写基地基于规则的PHP重写、规则、基地、PHP

由网友(ミ順⑦zī嘫)分享简介:内部网址: example.com/abc/xyz/rule.php?price=1&pass=2 外部URL: example.com/abc/xyz/rule/1/2 不过,CSS,JS文件都没有进入外部URL效果。我的.htaccess文件:RewriteEngine叙述上的RewriteBase /e...

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

不过,CSS,JS文件都没有进入外部URL效果。 我的.htaccess文件:

  RewriteEngine叙述上
的RewriteBase /example.com/abc/
重写规则^规则/([0-9] +)/([0-9] +)/ $ rule.php价格= $ 1安培;?通过= $ 2
 

解决方案

问题是相对URL是由客户端和服务器无法解析。而基本URL,相对URL被得到解决,是当前文档的URL。而在你的情况基本URL(路径) / ABC / XYZ /规则/ 1/2 ,而不是 /abc/xyz/rule.php ?价格= 1安培;通过= 2

现在可以通过多种方式来解决这个问题:

使用,可从实际的基础URL 正确解析相对URL / ABC / XYZ /规则/ 1/2 是独立于基础URL使用绝对路径 在塔子使用的基本URL HTML的 BASE 元素 PHPmd5文件生成规则利用与网站授权 求MD5生成规则

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

解决方案

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
阅读全文

相关推荐

最新文章