Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url 重写基本规则-php_Url_.htaccess_Mod Rewrite_Base Url - Fatal编程技术网

Url 重写基本规则-php

Url 重写基本规则-php,url,.htaccess,mod-rewrite,base-url,Url,.htaccess,Mod Rewrite,Base Url,内部URL:example.com/abc/xyz/rule.php?price=1&pass=2 外部URL:example.com/abc/xyz/rule/1/2 但是css、js文件在外部URL中没有生效。 我的.htaccess文件: RewriteEngine On RewriteBase /example.com/abc/ RewriteRule ^rule/([0-9]+)/([0-9]+)/?$ rule.php?price=$1&pass=$2 “问题”在于,相对U

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

外部URL:
example.com/abc/xyz/rule/1/2

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

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

“问题”在于,相对URL由客户端而不是服务器解决。而基础URL(从中解析的相对URL)是当前文档的URL。在您的例子中,基本URL(路径)是
/abc/xyz/rule/1/2
,而不是
/abc/xyz/rule.php?price=1&pass=2

现在有几种方法可以解决这个问题:

  • 使用可从实际基本URL正确解析的相对URL
    /abc/xyz/rule/1/2
  • 使用独立于基本URL的绝对URL
  • 使用

请将.htaccessORIGINAL URL:的内容重新编写为:但css、js文件在重新编写的URL中不生效。MY.htaccess文件:RewriteBase/example.com/abc/RewriteRule^rule/([0-9]+)/([0-9]+)/?$rule.php?price=$1&pass=$2请更新问题。只是一个建议。这与其说是一个PHP问题,不如说是一个Apache问题。如果您将其标记为这样,您可能会得到更多的响应。(如果将
.htaccess
文件格式化为代码,也会有所帮助。