Rewrite base rule- php

梦想的初衷 提交于 2019-12-13 05:48:26

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/3264285/rewrite-base-rule-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!