htaccess制作别名并重写规则

时间:2016-07-22 22:36:43

标签: .htaccess mod-rewrite url-rewriting

我在/html/test-html/index.html这里有html。还有像这样的CSS和图像:/html/test-html/css/style.css

当我在浏览器样式中打开index.html并正确加载图像时。

当我试图通过php echo函数渲染它的内容时,我遇到了404错误的问题,因为index.html和style.css中的路径是相对的,就像这样:

<link src="css/style.css" rel="stylesheet" type="text/css" />

因此,当我在脚本中回显index.html内容时(例如,通过类似http://localhost/product1的网址),浏览器会尝试通过此网址找到style.css:

http://localhost/css/style.css

但实际上文件位于

/html/test-html/css/style.css

我认为好主意是在http://localhost/html/test-html/中模拟类似浏览器的网址,但实际上我们在http://localhost/product1(使用RewriteRule),但没有重定向。

换句话说,我希望浏览器认为http://localhost/product1http://localhost/test-html,服务器认为http://localhost/product1http://localhost/index.php?r=product/view&id=1

有可能吗?

0 个答案:

没有答案
相关问题